I have pretty large app to inspect with a lot of activities. One of most popular exceptions is
No Activity found to handle Intent {
act=android.intent.action.WEB_SEARCH (has extras) }
What the heck? I don't see in code any "WEB_SEARCH" anywhere, I can't reproduce it, I don't even know where to look for cause (in which Activity). Below stack of Exception, without any class from my package... How to track and fix this?
Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.WEB_SEARCH (has extras) }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1659)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1434)
at android.app.Activity.startActivityForResult(Activity.java:3432)
at android.app.Activity.startActivityForResult(Activity.java:3393)
at android.support.v4.app.FragmentActivity.startActivityForResult(Unknown Source)
at android.app.Activity.startActivity(Activity.java:3628)
at android.app.Activity.startActivity(Activity.java:3596)
at android.webkit.SelectActionModeCallbackSec.onActionItemClicked(SelectActionModeCallbackSec.java:390)
at com.android.internal.policy.impl.PhoneWindow$DecorView$ActionModeCallbackWrapper.onActionItemClicked(PhoneWindow.java:3264)
at android.support.v7.view.SupportActionModeWrapper$CallbackWrapper.onActionItemClicked(Unknown Source)
at android.support.v7.app.AppCompatDelegateImplV7$ActionModeCallbackWrapperV7.onActionItemClicked(Unknown Source)
at android.support.v7.app.AppCompatDelegateImplV7$ActionModeCallbackWrapperV7.onActionItemClicked(Unknown Source)
at android.support.v7.view.StandaloneActionMode.onMenuItemSelected(Unknown Source)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(Unknown Source)
at android.support.v7.view.menu.MenuItemImpl.invoke(Unknown Source)
at android.support.v7.view.menu.MenuBuilder.performItemAction(Unknown Source)
at android.support.v7.view.menu.MenuBuilder.performItemAction(Unknown Source)
at android.support.v7.view.menu.MenuPopupHelper.onItemClick(Unknown Source)
at android.widget.AdapterView.performItemClick(AdapterView.java:301)
at android.widget.AbsListView.performItemClick(AbsListView.java:1490)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3275)
at android.widget.AbsListView$1.run(AbsListView.java:4518)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5283)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(NativeStart.java)
I have to answer my own question for another future searchers. For use in Activity with WebView, or for safety in some Base/MainActivity abstract layer:
#Override
public void startActivityForResult(Intent i, int reqCode, Bundle b){
boolean activityExists = i.resolveActivityInfo(getPackageManager(), 0) != null;
if(activityExists)
super.startActivityForResult(i, reqCode, b);
else{
if(Intent.ACTION_WEB_SEARCH.equals(i.getAction()) && i.getExtras()!=null){
String query = i.getExtras().getString(SearchManager.QUERY, null);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.pl/search?q="+query));
boolean browserExists = i.resolveActivityInfo(getPackageManager(), 0) != null;
if(browserExists && query!=null){
startActivity(browserIntent);
return;
}
}
Toast.makeText(this, R.string.error_no_app_for_intent, Toast.LENGTH_LONG).show();
}
}
Reason of this behaviour is (probably) custom system UI/modded Android made by hardware producer, which is adding some features related with searching. Not reproducable on "clean" Android device
Met the same issue recently, did some dig, i think snachmsm's answer is good, and i wanna make some analysis for other searchers.
Obviously no code written by me is starting an Intent with WEB_SEARCH, and according to the crash log, the intent is invoked by android.webkit.SelectActionModeCallbackSec.onActionItemClicked, so the fact is that if you use a webview, when the user long click and select some text , in some phones or themes or ROMs it will show an ActionMenu with "find" and "web search" or only one of them, depends on the various implementation. And when the user click "web search" it will start an intent with WEB_SEARCH.
Then the solution is simple, in the Activities that use a webview, override startActivityForResult to handle the certain intent. Why don't he override startActivity either? Because startActivity invoke startActivityForResult eventually.
Related
I am using JItsi meet api for video call on linphone android app open source project. I have followed jitsi meet handbook for integrating on linphone.
Here is my sample code:
public class JitsiActivity extends AppCompatActivity {
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
URL serverURL;
try {
serverURL = new URL("https://meet.jit.si");
} catch (MalformedURLException e) {
e.printStackTrace();
throw new RuntimeException("Invalid server URL!");
}
JitsiMeetConferenceOptions defaultOptions =
new JitsiMeetConferenceOptions.Builder()
.setServerURL(serverURL)
.setWelcomePageEnabled(false)
.build();
JitsiMeet.setDefaultConferenceOptions(defaultOptions);
JitsiMeetConferenceOptions options =
new JitsiMeetConferenceOptions.Builder().setRoom("linphone").build();
JitsiMeetActivity.launch(this, options);
finish();
}
}
I have successfully made a call on debug mode, after making an apk on release mode, It refresh activity when I attempt to make a video call and go to home page. can you give me a guideline to solve this problem. I have tested apk on Android 10 OS.
--After Debugging on release mode I have found this error
020-09-24 16:50:12.383 10364-10364/org.linphone E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.linphone, PID: 10364
java.lang.IllegalArgumentException: reportSizeConfigurations: ActivityRecord not found for: Token{2329006 ActivityRecord{cf5fae1 u0 org.linphone/.activities.JitsiActivity d-1 s-1 t-1 f}}
at android.os.Parcel.createException(Parcel.java:1967)
at android.os.Parcel.readException(Parcel.java:1931)
at android.os.Parcel.readException(Parcel.java:1881)
at android.app.IActivityManager$Stub$Proxy.reportSizeConfigurations(IActivityManager.java:8621)
at android.app.ActivityThread.reportSizeConfigurations(ActivityThread.java:3360)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3318)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:113)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:71)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2043)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7096)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:928)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActivityManagerService.reportSizeConfigurations(ActivityManagerService.java:10305)
at android.app.IActivityManager$Stub.onTransact$reportSizeConfigurations$(IActivityManager.java:12560)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2357)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3841)
at android.os.Binder.execTransact(Binder.java:750)
You need to provide a stacktrace to for anyone to help you debug it, however, this code can be simplified greatly which would lead to easier debugging..
You are supplying Jitsi with it's own default server url "https://meet.jit.si" which isn't necessary as Jitsi will use it's own server anyway. If you were planning on using your own server you can still provide that easily in the JitsiMeetActivity::launch method as the room parameter...
JitsiMeetActivity.launch(context, "https://myserver.com/linphone")
Removing all the unnecessary boiler-plate will leave you with this:
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
JitsiMeetActivity.launch(this, "linphone");
}
We released a beta of our product, it works for most users, but one user with OnePlus 5T/Android 8.1 reports a sporadic exception:
java.lang.RuntimeException: Unable to resume activity {com.ourproduct/com.ourproduct.MainActivity}: java.lang.IllegalArgumentException: Unknown URL content://com.ourproduct.data/delete
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3726)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3766)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1737)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6753)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by:java.lang.IllegalArgumentException: Unknown URL content://com.ourproduct.data/delete
at android.content.ContentResolver.delete(ContentResolver.java:1745)
<... here is our code stacktrace ...>
I contacted the user and got some additional info: the issue does not happen every time he uses the operation, just sometimes.
The content provider is defined in the same application.
The code is trivial, just for completeness of the question:
protected void unsetValue(final String group, final String name) {
myContext.getContentResolver().delete(
uri("delete"), null, new String[] { group, name }
);
}
private Uri uri(String location) {
return Uri.parse("content://com.ourproduct.data/" + location);
}
Any ideas? Maybe I can ask the user for some additional info?
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I need to send binary content from my app to whatever app opens that file type in the device.
I'm following these instructions:
https://developer.android.com/training/sharing/send.html#send-binary-content
Here's my code:
final FileType fileType
final File file;
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(AncestryApplication.getAppContext(), AncestryApplication.getAppContext().getApplicationContext().getPackageName() + ".provider", file));
intent.setType(fileType.getMimeType());
startActivity(intent);
A few things:
If I change the intent action from ACTION_VIEW to ACTION_SEND, I get the wrong possible list of apps to open my file
ACTION_SEND seems to work, but only with small file sizes
intent.setDataAndType() seems to work fine on devices OS M and lower. On N I get the same TransactionTooLargeException
At the end, this is what I need to accomplish:
I already have a file saved, and it is stored at file:///storage/emulated/0/Download/TempFile.html
Since the file may be too large, I need to send just the location of the file to a third party app (like adobe pdf reader) to open the file
No issues on M or lower, tons of issues on N
Any ideas on what I may be doing wrong? I've been trying to solve this for a few days and I've read a ton of tutorials and SO suggestions, without any final answer.
Thanks.
EDIT: here's my stacktrace:
AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.android.apps.myapp, PID: 26785
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 27943540 bytes
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3752)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.os.TransactionTooLargeException: data parcel size 27943540 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:615)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3606)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3744)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
EDIT 2: Added onSaveInstanceState() code from base fragment:
#Override
public void onSaveInstanceState(final Bundle outState) {
mSaveInstanceStateCalled = true;
outState.putBoolean(KEY_PROCESSING_SAVE, mSaveInProgress);
}
The exception in the logcat you posted is caused by packing too much data into the Bundle processed by onSaveInstanceState.
Here is the method from the Android source where it is thrown, if the build version is N or greater:
private static class StopInfo implements Runnable {
ActivityClientRecord activity;
Bundle state;
PersistableBundle persistentState;
CharSequence description;
#Override public void run() {
// Tell activity manager we have been stopped.
try {
if (DEBUG_MEMORY_TRIM) Slog.v(TAG, "Reporting activity stopped: " + activity);
ActivityManagerNative.getDefault().activityStopped(
activity.token, state, persistentState, description);
} catch (RemoteException ex) {
if (ex instanceof TransactionTooLargeException
&& activity.packageInfo.getTargetSdkVersion() < Build.VERSION_CODES.N) {
Log.e(TAG, "App sent too much data in instance state, so it was ignored", ex);
return;
}
throw ex.rethrowFromSystemServer(); // <<-- exception thrown here
}
}
}
I am posting this in the form of an answer because it's too long for a comment. It is not meant as a complete answer to the question, because there is not enough information in the question to answer it.
I have Main Activity which Opens a Fragment like this.
Fragment fragment = null;
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
switch (position) {
case 0:
fragment = new MyFragment();
break;
default:
break;
}
if (fragment != null) {
fragmentManager.beginTransaction().replace(R.id.frame_container,fragment).commit();
}
This Fragment contains a List View. On Taping the list item New Activity Opened like this.
Intent intent = new Intent(getActivity(), MyActivity.class);
startActivity(intent);
From this Activity I opened a link in browser like this.
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
Now here is the issue. If we opens a simple web link it works fine but if link contains an Application link of Play Store, on returning back from browser App crashed. On Htc and Nexus devices it is working fine but on Samsung S3 App crashed on returning from browser.
From Debuging i found that my Main fragment is null on Samsung S3 devices.
My Log Cat shows this.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.codenterprise.CashbackKorting/com.codenterprise.left.fragment.shops.ShopComplateDetailActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
at android.app.ActivityThread.access$600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.codenterprise.general.Services.<init>(Services.java:74)
at com.codenterprise.general.Services.<init>(Services.java:70)
at com.codenterprise.left.fragment.shops.ShopComplateDetailActivity.onCreate(ShopComplateDetailActivity.java:90)
at android.app.Activity.performCreate(Activity.java:5206)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
Thanks
Devices with less memory kills your application to save memory when your application goes to background. So try to save and restore the state of your application before and after going to browser, like in the below code
Save the state
#Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
and retrieve it in the same activity
#Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
}
I am testing my billing and I got this exception:
java.lang.IllegalStateException: Can't start async operation (launchPurchaseFlow) because another async operation(launchPurchaseFlow) is in progress.
at utils.IabHelper.flagStartAsync(IabHelper.java:711)
at utils.IabHelper.launchPurchaseFlow(IabHelper.java:316)
at utils.IabHelper.launchPurchaseFlow(IabHelper.java:294)
at com.problemio.SubscribeIntroActivity$6.onClick(SubscribeIntroActivity.java:117)
at android.view.View.performClick(View.java:2532)
at android.view.View$PerformClick.run(View.java:9308)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
After I ran this code:
Button subscribe = (Button)findViewById(R.id.subscribe);
subscribe.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
// FIRST CHECK IF THE USER IS ALREADY A SUBSCRIBER.
mHelper.launchPurchaseFlow(SubscribeIntroActivity.this, SUBSCRIBE_SKU, RC_REQUEST, mPurchaseFinishedListener);
}
});
But prior to this I ran it as a test user and with the test product id which was this: android.test.purchased and it worked. But when I changed product id to one of my own products ids, it crashed with the exception above.
Any ideas why that happened?
Thanks!
The IabHelper will only allow a single asynchronous query to be executed at a time. You need to implement onActivityResult() and pass the parameters into the handleActivityResult() method of the IabHelper.
The in-app billing sample code implements the method like this:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
// not handled, so handle it ourselves (here's where you'd
// perform any handling of activity results not related to in-app
// billing...
super.onActivityResult(requestCode, resultCode, data);
}
else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}
Just in case someone is missing the forest for the trees like I was...
I received a java.lang.IllegalStateException stack trace in the Play Developer Console which didn't provide much more than the error message... so I was stumped.
I couldn't figure out how this was happening at first because I never thought to try tapping the button that triggers IAB twice! (it looks disabled after the first tap due to an overlay that let's taps through, [sometimes]).
So, make sure your users can't tap your button twice.
You are using sample code of google and in IabHelper class line 793 there is this piece of code
if (mAsyncInProgress) throw new IllegalStateException("Can't start async operation (" +
operation + ") because another async operation(" + mAsyncOperation + ") is in progress.");
and when you make a purchase for first time 'mAsyncInProgress' becomes true,and until you haven't consumed your purchase it remains true ,so you need to consume your purchase.
I recommend you to read all Classes in util package completely,it will help you.
after any successful purchase you need to consume it
mHelper.consumeAsync(purchase, mConsumeFinishedListener)
but sometimes the consume request fails so you need to handle your purchases every time your activity is created :
mHelper.queryInventoryAsync(mGotInventoryListener);
and try to consume your purchases in mGotInventoryListener callback.
get the latest version of the library here: https://code.google.com/p/marketbilling/source/browse/ where they fixed the problem