Tag: android-intent

Android BroadCastReceiver for volume key up and down

If a user presses volume key up or down is it possible to detect it in my broadcast receiver? I need the full code. Here is my Intent filter IntentFilter filter = new IntentFilter(); filter.addAction(“android.media.VOLUME_CHANGED_ACTION”); and my onReceive method is public void onReceive(Context arg0, Intent intent) { KeyEvent ke = (KeyEvent)intent.getExtras().get(Intent.EXTRA_KEY_EVENT); if (ke .getKeyCode() == […]

How to add flags with my intent in the manifest file

we know that there are flags which we can add to our intent using the addFlags() method in our java code. Is there any way we can add these flags in the manifest file itself instead of writing this in java code. I need to add REORDER_TO_FRONT flag for one of my activities in the […]

Android: Use icon as back button without reloading previous activity

I have the following code to enable to home button to act as a back button. The problem I’m facing is from this activity if I use the real back button it simply goes back to the previous activity just as I left it. If I use the home button it’s reloading the page so […]

Starting a Song from Spotify Intent

Is there anyway to start a Spotify Track from its URI ? I’ve tried the following approaches but none of them work. When Spotify opens, it always lands in the Playlists page, instead of the track’s player. String spotifyTrackURI = “spotify:track:1cC9YJ8sQjC0T5H1fXMUT2”; Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(“com.spotify.mobile.android.ui”); // I’ve tried with Intent#putExtra().. launchIntent.putExtra( SearchManager.QUERY, spotifyTrackURI ); // […]

Which Intent for Settings – Data usage

I spent several hours by searching correct Intent for launching Data usage Activity in Android Settings. Unfortunetly i found nothing (on web and also here). I also tried reflection (in a case of private field) but also without result. I will be glad for any help. Thanks in advance.

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 […]

Using LocalBroadcastManager for 'sticky' broadcast

Am I correct in thinking that I cannot send ‘sticky’ broadcasts using LocalBroadcastManager ? If so this seems very short-sighted particularly if an app uses Fragments that can be swapped in and out during the app lifecycle and relies on broadcast data..

Android device GPS on/off programatically

I am using following code for GPS on/off. //Enable GPS Intent intent = new Intent(“android.location.GPS_ENABLED_CHANGE”); intent.putExtra(“enabled”, true); context.sendBroadcast(intent); //Disable GPS Intent intent = new Intent(“android.location.GPS_ENABLED_CHANGE”); intent.putExtra(“enabled”, false); context.sendBroadcast(intent); Programatically I need to on/off GPS on android device. I am using above code for that. But It doesn’t work on all the devices. Please help me. […]

Showing all broadcast events on Android

is it somehow possible to show all broadcast events/intents that are triggered in android? I just want to know if I can quickly figure out if an application is using intents/broadcasts I can hook into. For most of the stock android applications I can read the source but is time consuming.

intent.putExtra() in pending intent not working

I am passing a pending intent through alarmreceiver, from a service class. But, after the pendingIntent fires, the intent.putExtra() information is not being received by the broadcastreceiver class. Here is my code for firing the pendingIntent Intent aint = new Intent(getApplicationContext(), AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), id, aint, PendingIntent.FLAG_UPDATE_CURRENT); aint.putExtra(“msg”, msg); aint.putExtra(“phone”, phone); alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), […]

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