Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Intent.ACTION_SEND handling back action

I have a bug in my app and I didnt find anyone talking about the same problem.

This is how I am creating my intent:

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, shareContent);
shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share Image"));

And this works fine, the problem is that if I try to return to my app, it is not responding back. How do I solve that?

I tried using:

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
}

But this doesn't solve my problem.

Does anyone have any idea how to solve this?

This is my logcat:

Caught a RuntimeException from the binder stub implementation.
                                                                          java.lang.NullPointerException: Attempt to invoke interface method 'android.os.IBinder com.mediatek.anrappmanager.IFrameworks.serviceManagerGetService(java.lang.String)' on a null object reference
                                                                              at com.mediatek.anrappmanager.ANRManagerNative$1.b(SourceFile:77)
                                                                              at com.mediatek.anrappmanager.ANRManagerNative$1.c(SourceFile:75)
                                                                              at com.mediatek.anrappmanager.ANRManagerNative$a.get(SourceFile:97)
                                                                              at com.mediatek.anrappmanager.ANRManagerNative.getDefault(SourceFile:35)
                                                                              at com.mediatek.anrappmanager.ANRAppManager.dumpMessageHistory(SourceFile:59)
                                                                              at android.app.ActivityThread$ApplicationThread.dumpMessageHistory(ActivityThread.java:1244)
                                                                              at android.app.ApplicationThreadNative.onTransact(ApplicationThreadNative.java:682)
                                                                              at android.os.Binder.execTransact(Binder.java:451)  
like image 948
Lucas Storti Avatar asked Sep 04 '26 15:09

Lucas Storti


1 Answers

Delete this line:-

shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);

When you flag the intent as a new intent, it causes a logical break in your application.You do this when you want to show the next activity being launched separately in your recent apps section.

like image 106
yash sachdeva Avatar answered Sep 06 '26 03:09

yash sachdeva