My app is supposed to handle shared texts. For example URLs from the amazon app. So I added the following intent-filter to my main activity:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
In my onCreate function of my activity, I'm processing the intent like so:
intent = getIntent();
if(intent.getAction() != null) {
if (intent.getAction().equals(Intent.ACTION_SEND)) {
if (intent.getType().equals("text/plain")) {
onNavigationDrawerItemSelected(1);
}
}
}
The problem is, that sometimes the onCreate function isn't called following a sharing action. I checked the onResume method, and indeed that's what is called. The problem is that the intents action isn't "ACTION_SEND", but is packagename.handled and doesn't contain the needed information.
Why is that?
The Intent is not deprecated the problem is with your itemClickable. class because it is not recognized. Either you have somehow enabled extra warnings that identify Intent as deprecated or something is really stack at your machine.
Android Intent is the message that is passed between components such as activities, content providers, broadcast receivers, services etc. It is generally used with startActivity() method to invoke activity, broadcast receivers etc. The dictionary meaning of intent is intention or purpose.
An intent is an object that can hold the os or other app activity and its data in uri form.It is started using startActivity(intent-obj).. \n whereas IntentFilter can fetch activity information on os or other app activities.
If your activity already exists, depending on Intent
flags and <activity>
attributes, that existing activity instance may be reused. Override onNewIntent()
to get the Intent
being delivered to an existing activity instance that is causing it to be brought back to the foreground. Look in there for your ACTION_SEND
values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With