Skip to content

Instantly share code, notes, and snippets.

View ekoRemDev's full-sized avatar
🌍
Coding

Eko ekoRemDev

🌍
Coding
View GitHub Profile
Handler handler = new Handler();
handler.postDelayed(new Runnable(){
@override
public void run(){
Toast(......);
}
},5000);
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (remoteMessage.getNotification() != null) {
String title = remoteMessage.getNotification().getTitle();
String body = remoteMessage.getNotification().getBody();
public class NotificationHelper {
public static void displayNotification(Context context, String title, String body) {
Intent intent = new Intent(context, ActivityMain.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
context,
100,
intent,
PendingIntent.FLAG_CANCEL_CURRENT
<service android:name=".model.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
package app.yourpackagename.bounce;
//
// Interpolator to be used with Android view Animation class to achieve the spring-bounce effect.
//
// License: MIT
// Source: http://evgenii.com/blog/spring-button-animation-on-android/
//
// Usage example, make the button wobble in scale:
// ------------
void animateMenuItem() {
// Load the animation Bounce
final Animation myAnimBounce = AnimationUtils.loadAnimation(this, R.anim.bounce);
final Animation myAnimBounce2 = AnimationUtils.loadAnimation(this, R.anim.bounce2);
// double animationDuration = getDurationValue() * 1000;
double animationDuration = 2 * 1000;
myAnimBounce.setDuration((long)animationDuration);
// Use custom animation interpolator to achieve the bounce effect
@ekoRemDev
ekoRemDev / Android - Set window fullscreen and remove title bar, and force landscape orientation
Created September 6, 2019 07:04
Android - Set window fullscreen and remove title bar, and force landscape orientation
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set window fullscreen and remove title bar, and force landscape orientation
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intentMainActivity = new Intent(Welcome.this, MainActivity.class);
intentMainActivity.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intentMainActivity);
finish();
}
},SPLASH_TIME);
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
public class ClassName {
private static ClassName instance;
private ClassName(){
// Private to prevent anyone else from instantiating
}
public static ClassName getInstance(){
if(instance == null){
instance = new ClassName();