start-activity

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

我与影子孤独终老i 提交于 2019-11-27 11:23:37
问题 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. 回答1: Try using Intent.EXTRA_TEXT

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

风流意气都作罢 提交于 2019-11-27 01:00:18
问题 What is the difference between startActivityForResult() and startActivity() ? When, and for what, should I use each one ? 回答1: 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.

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

寵の児 提交于 2019-11-26 19:22:10
问题 This question already has answers here : How to finish current activity in Android (7 answers) Closed 5 years ago . 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? 回答1: 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

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

旧城冷巷雨未停 提交于 2019-11-26 16:30:27
问题 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? 回答1: You need to pass a

How to start activity in another application?

吃可爱长大的小学妹 提交于 2019-11-26 01:39:27
问题 I have application A defined as below: <application android:icon=\"@drawable/icon\" android:label=\"@string/app_name\"> <activity android:name=\"com.example.MyExampleActivity\" android:label=\"@string/app_name\"> <intent-filter> <action android:name=\"android.intent.action.MAIN\" /> <category android:name=\"android.intent.category.LAUNCHER\" /> </intent-filter> </activity> </application> Now in application B, how can I write the code to start the activity in application A? Thanks! 回答1: If you