start-activity

When I return back to my Activity onCreate is raised instead of onActivityResult?

流过昼夜 提交于 2019-11-29 17:01:20
I have an Activity that opens a new Activity for result like this: Intent i = new Intent(ActDocument.this, ActCustomers.class); startActivityForResult(i, ActDocument.DIALOG_CUSTOMER); when I press back in the child Activity and return back to the parent Activity onActivityResult is called in all of devices correctly but I have fount a device that onCreate is called instead of onActivityResult . This device is Samsung Galaxy Tab-P5100 Android 4.0.3. It is strange that I have tested my application on other devices of Samsung Galaxy Tab-P5100 Android 4.0.3 and it was OK but I have problem only in

How can I send message to specific contact through WhatsApp from my android app?

☆樱花仙子☆ 提交于 2019-11-28 18:29:58
I am developing an android app and I need to send a message to specific contact from WhatsApp. I tried this code: Uri mUri = Uri.parse("smsto:+999999999"); Intent mIntent = new Intent(Intent.ACTION_SENDTO, mUri); mIntent.setPackage("com.whatsapp"); mIntent.putExtra("sms_body", "The text goes here"); mIntent.putExtra("chat",true); startActivity(mIntent); The problem is that the parameter "sms_body" is not received on WhatsApp, though the contact is selected. Try using Intent.EXTRA_TEXT instead of sms_body as your extra key. Per WhatsApp's documentation, this is what you have to use. An example

When I return back to my Activity onCreate is raised instead of onActivityResult?

一世执手 提交于 2019-11-28 12:03:47
问题 I have an Activity that opens a new Activity for result like this: Intent i = new Intent(ActDocument.this, ActCustomers.class); startActivityForResult(i, ActDocument.DIALOG_CUSTOMER); when I press back in the child Activity and return back to the parent Activity onActivityResult is called in all of devices correctly but I have fount a device that onCreate is called instead of onActivityResult . This device is Samsung Galaxy Tab-P5100 Android 4.0.3. It is strange that I have tested my

Difference between startActivityForResult() and startActivity()? [closed]

前提是你 提交于 2019-11-28 05:40:52
What is the difference between startActivityForResult() and startActivity() ? When, and for what, should I use each one ? startActivity Start an activity, like you would start an application: for instance: you have an app with a home-screen and a user-info screen: if you press the user-info button, you start the user-info activity with this. startActivityForResult Start an activity and expect something in return. For instance, on your user-info screen, you can upload a profile picture. You start the gallery-activity with the explicit goal to get a URI back with the preferred picture. You start

How to get startActivityForResult on external Activity to work?

被刻印的时光 ゝ 提交于 2019-11-28 04:20:58
问题 Searching high and low has yielded no result for my problem. Hence I'm finally posting to plead for some assistance. I have two app, both written by me. App A launches App B, passing in parameters through Intent.putExtra(). This works perfectly fine when App B is launched the parameters are passed nicely. However, I can't find a way to return a response to App A. Using startActivityForResult() always gave me immediate onActivityResult() with RESULT_CANCELED. Upon further inspection, the

Setting up Alarm Manager is creating 2 Instances of my Main Activity

大兔子大兔子 提交于 2019-11-28 01:44:46
I have 2 activities, a Main Activity and SetAlarm Activity. I call SetAlarm Activity from Main. When I set up the alarm I create an instance of my main. How do I set up the alarm without creating another instance of the Main or do I kill the main before setting up the alarm? Quite new to this. I have read several of the alarm manager examples, but they all seem to set up a new intent and I think this is what is creating my 2 instances. Is this how you set up the alarm. It does go off. Here is how I call SetAlarm from the Main: public void setAlarm(View view) { Intent intent = new Intent(this,

StartActivityForResults always returns RESULT_CANCELLED for Intent.ACTION_SEND

谁说胖子不能爱 提交于 2019-11-27 20:41:35
As the share pop up appears, I shared the content on WhatsApp successfully, but still returns RESULT_CANCELLED. Same result when I send a email using Gmail. Calling Sharing intent, ACTION_SEND with startActivityForResult always returns CANCELLED Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_TITLE, "Taxeeta, Cab Around The Curb"); sharingIntent .putExtra( android.content.Intent.EXTRA_TEXT, "Hiring a cab no longer needs you to wait on call centers, or pay a" + " convenience (yeah right!!) charge.

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.USAGE_ACCESS_SETTINGS }

廉价感情. 提交于 2019-11-27 18:37:07
问题 This issue is happening on Android 5.0 Lollipop only. I dont have access to a phone with Lollipop, I have developed the code in Genymotion Android Emulator but this issue does not happen in the emulator. I am only getting failing stacktraces from users' phones. My Code: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS); startActivity(intent); } The App crashes and the stacktrace I am getting from users: android

Start new Activity and finish current one in Android? [duplicate]

冷暖自知 提交于 2019-11-27 18:15:53
This question already has an answer here: How to finish current activity in Android 7 answers Currently I'm starting a new Activity and calling finish on a current one. Is there any flag that can be passed to Intent that enables finishing current Activity without a need to call finish manually from code? You can use finish() method or you can use: android:noHistory="true" And then there is no need to call finish() anymore. <activity android:name=".ClassName" android:noHistory="true" ... /> Avi Kumar Manku Use finish like this: Intent i = new Intent(Main_Menu.this, NextActivity.class); finish()

java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode

北战南征 提交于 2019-11-27 14:16:52
I am writing an application where Activity A launches Activity B using startActivityForResult(intent, -101); but when called, it responded back with following error log: E/AndroidRuntime( 1708): java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode E/AndroidRuntime( 1708): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:837) Probably it could be -101 but I am not sure. Does any one have any idea on this? Stephane Mathis You need to pass a positive number to startActivityForResult . Henry You get this exception only in android