Start Android with Email

I need a good way to send information to an Android device that does not use a special server with XML data. I would like to base this on email features. Let's say that I am sending an email with a special text / link, which when clicked starts with the intent on the phone.

I do not want to replace the current user email application. An interchangeable link would be the best "intent: // data1: data2" or something in that direction.

Speculation / decisions on how to act.

+4
source share
1 answer

Yes you can do it. You register activity in your application as a handler for your own protocol (scheme). The application manifest will be something like:

<activity android:name=".SchemeActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="myownprotocol" /> </intent-filter> </activity> 

This action will not be displayed or get an icon in the application launcher, so you are likely to have β€œnormal” activity in addition to this.

Now any web page can have a link, as shown below:

 <a href="myownprotocol://12345">Sample link</a> 

With the application installed, you can click such a link in a web browser and display SchemeActivity in my example. Inside this action, you can get the whole link (and parse the extra identifier / data or whatever you have):

 String fullUrl = getIntent().getDataString(); 
+2
source

Source: https://habr.com/ru/post/1305101/


All Articles