BroadcastReceiver for ACTION_MEDIA_BUTTON not working

I tested this on a Samsung Galaxy S5 with Android 4.4.2. So what is important and what is not mentioned in other posts: Register the receiver in the AndroidManifest.xml inside the application tag but outside from every activity tag. Your receiver Broadcastreceiver need to be public and static One activity need to register an MediaButtonEventReceiver … Read more

Activity stack ordering problem when launching application from Android app installer and from Home screen

Added the answer that antonyt provided: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { // Activity was brought to front and not created, // Thus finishing this will get us to the last viewed activity finish(); return; } // Regular activity creation code… }

How to attach image from drawable to gmail?

Here is the working code which you need: Firstly save image from Drawable to SD Card here is the code: try{ Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.bubble_green); //replace “R.drawable.bubble_green” with the image resource you want to share from drawable ByteArrayOutputStream bytes = new ByteArrayOutputStream(); largeIcon.compress(Bitmap.CompressFormat.JPEG, 40, bytes); // you can create a new file name “test.jpg” … Read more

Passing ArrayList of string arrays from one activity to another in android

Not sure what you mean by “ArrayList of string arrays” If you have string array then check the below link Passing string array between android activities http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html ArrayList implements Serializable You can use intents ArrayList<String> mylist = new ArrayList<String>(); Intent intent = new Intent(ActivityName.this, Second.class); intent.putStringArrayListExtra(“key”, mylist); startActivity(intent); To retrieve Intent i = getIntent(); ArrayList<String> … Read more

Share image and text through whatsapp

Whatsapp Support Image sharing along with text. Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT,title + “\n\nLink : ” + link ); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imageFilePath)); shareIntent.setType(“image/*”); startActivity(Intent.createChooser(shareIntent, “Share image via:”)); This will share image and EXTRA_TEXT will consider as image caption.

Google Photos vs Stock Gallery – Intent Picker

Solution First, update the photoPickerIntent to use ACTION_GET_CONTENT, and remove the extras related to cropping, since cropping will be handled by another Intent later: Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT); photoPickerIntent.setType(“image/*”); // Do not include the extras related to cropping here; // this Intent is for selecting the image only. startActivityForResult(photoPickerIntent, RESULT_LOAD_IMAGE); Then, onActivityResult() will have … Read more

Pass Serializable Object to Pending Intent

There are known issues with putting custom objects into an Intent that is then passed to AlarmManager or NotificationManager or other external applications. You can try to wrap your custom object in a Bundle, as this will sometimes work. For example, change your code to: Intent myIntent = new Intent(getApplicationContext(), AlarmAlertBroadcastReciever.class); Bundle bundle = new … Read more

How to run an activity only once like Splash screen

This is how I achieved it!Hope it helps! import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; public class check extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); SharedPreferences settings=getSharedPreferences(“prefs”,0); boolean firstRun=settings.getBoolean(“firstRun”,false); if(firstRun==false)//if running for first time //Splash will load for first time { SharedPreferences.Editor editor=settings.edit(); editor.putBoolean(“firstRun”,true); editor.commit(); Intent i=new … Read more