Tag: android-activity

How to make background Activity smaller while opening the Navigation Drawer?

I want to make my background Activity a little bit smaller while opening the Navigation Drawer, Simulate the effect that exists in the Airbnb application. I guess the best explanation would be a screenshot: But the point is not to make the View just smaller, but to make it an animation that is synchronized to […]

Removing an entry from an Bundle (i.e. extras) doesn't seem to work in combination with the back button

I have a BroadcastReceiver that listen to incoming SMS’. If the message is from a certain sender, the BroadcastReceiver starts my app with the following code: final Intent activityIntent = new Intent(context, MainActivity.class); activityIntent.putExtra(“smsChallenge”, smsText); activityIntent.putExtra(“smsSenderNumber”, senderMobilNumber); activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(activityIntent); In the MainActivity of my app (i.e. in onCreate()), I extract the value smsChallenge out […]

Activity side-by-side lifecycle

Imagine that I have an Activity A and I’m starting a new activity B from that one. What will be the Activities lifecycle side-by-side? 1. A: onCreate 2. A: onStart 3. A: onResume on A => startActivity(B) 4. B: onCreate 5. B: onStart 6. A: onPause 7. B: onResume 8. A: onStop Is this correct?

Start Activity Android with class name

I am using Following Code to start setting I want to launch the setting activity which is started by android ins PackageList allowedAppsPackageName=CallHelper.Ds.getPackageList(); PackageManager manager = CallDetectService.packageManager; Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0); Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager)); final int count = apps.size(); ResolveInfo info=new ResolveInfo();; GridViewAppList.clear(); for (int i […]

Click on notification starts activity twice

I’m creating a notification from a service with the following code: NotificationManager notificationManager = (NotificationManager) ctx .getSystemService(Context.NOTIFICATION_SERVICE); CharSequence tickerText = “bla …”; long when = System.currentTimeMillis(); Notification notification = new Notification(R.drawable.icon, tickerText, when); Intent notificationIntent = new Intent(ctx, SearchActivity.class). putExtra(SearchActivity.INTENT_SOURCE, MyNotificationService.class.getSimpleName()); PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, 0); notification.setLatestEventInfo(ctx, ctx.getString(R.string.app_name), tickerText, contentIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; […]

Calling findViewById() from outside an activity

Is there any way to access a layout’s view from a non-Activity-derived class? I’m creating an Accordion class and need to access some of the activity’s UI elements. I’m passing in the activity’s context to my accordion class’s constructor, but the findViewById API is only available from the Activity class. I also don’t want to […]

It is necessary to initialize Firebase Analytics in every Activity?

I donĀ“t want to send any special logs to the Firebase Analytics console, just check in which screens is the user spending more time and so on. When I used AnalyticsTracker it was compulsory to add it everywhere, so do you can set the specific name of every screen with the Tracker.xml file. The official […]

Android: Launch mode 'single instance'

I was going through the documentation for single instance and was trying out few samples. In one of my sample I have three activities: A->B->C , where B has android:launchMode=”singleInstance” in manifest. Activity A and C has default launch mode. Scenario: After navigating to C via A and B (i.e A->B->C), back button press from […]

How to check if the current activity has a dialog in front?

I am using a third-party library and sometimes it pops up a dialog. Before I finish the current activity, I want to check whether there is a dialog popped up in the current context. Is there any API for this?

Fullscreen in WindowManager

This is my code: params = new WindowManager.LayoutParams( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, PixelFormat.TRANSLUCENT); wm = (WindowManager) getApplicationContext() .getSystemService(Context.WINDOW_SERVICE); inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); mTopView = (ViewGroup) inflater.inflate( R.layout.activity_invisible, null); params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_DIM_BEHIND | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |WindowManager.LayoutParams.FLAG_FULLSCREEN; if(keep==true){ int value = brightnessIntent.getExtras().getInt(“value”); float v=value/255.0f; params.dimAmount=0; params.alpha=v; rl = (RelativeLayout) mTopView.findViewById(R.id.window); getWindow().setAttributes(params); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); wm.addView(mTopView, params); […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.