Proposal for invoking web apps from an Android app through web intents (OI WebIntents Agent)

67 views
Skip to first unread message

Cheng Zheng

unread,
Jul 27, 2012, 12:27:26 AM7/27/12
to openi...@googlegroups.com, Friedger Müffke
Hi everyone,

I tested some methods and now the following one to call web apps from and Android app seems best feasible.

A new class named org.openintents.wiagent.WebIntentsHelperActivity is added and exported. So any android app which needs to invoke web intents can send an explicit intent object to start this activity. The values of action, type, data should be put into the extra fields. 

For example, if you want to invoke share action from an Android app, the following snippet can do it.

Intent intent = new Intent();
intent.putExtra("action", android.content.Intent.ACTION_SEND);
intent.putExtra("type", "text/uri-list");
intent.putExtra("data", "http://paul.kinlan.me");
intent.setComponent(new ComponentName("org.openintents.wiagent","org.openintents.wiagent.WebIntentsHelperActivity"));
                
startActivity(intent); 

I've created a simple app which works according to this way (under the directory of android app samples) and upload it to github. Please let me know if you have any feedback..

Thanks

Cheng Zheng

Friedger

unread,
Jul 27, 2012, 1:48:10 AM7/27/12
to Cheng Zheng, openi...@googlegroups.com, Friedger Müffke
Why don't you use setType and setData?
What about implicit intents?

As a developer I don't care wether the user wants to use an Android app or webapp.

Cheng Zheng <czhe...@gmail.com> wrote:

>Hi everyone,
>
>I tested some methods and now the following one to call web apps from and
>Android app seems best feasible.
>
>A new class named org.openintents.wiagent.WebIntentsHelperActivity is added
>and exported. So any android app which needs to invoke web intents can send

>an *explicit* intent object to start this activity. The values of action,


>type, data should be put into the extra fields.
>
>For example, if you want to invoke share action from an Android app, the
>following snippet can do it.
>
>Intent intent = new Intent();
>intent.putExtra("action", android.content.Intent.ACTION_SEND);
>intent.putExtra("type", "text/uri-list");
>intent.putExtra("data", "http://paul.kinlan.me");
>intent.setComponent(new
>ComponentName("org.openintents.wiagent","org.openintents.wiagent.WebIntentsHelperActivity"));
>
>startActivity(intent);
>
>I've created a simple app which works according to this way (under the

>directory of *android app samples*) and upload it to github. Please let me

Friedger Müffke

unread,
Jul 28, 2012, 5:40:31 PM7/28/12
to Cheng Zheng, openi...@googlegroups.com, Friedger Müffke
2012/7/27 Cheng Zheng <czhe...@gmail.com>:
> Hi,
>
> On Fri, Jul 27, 2012 at 1:48 AM, Friedger <frie...@gmail.com> wrote:
>>
>> Why don't you use setType and setData?
>
>
> It seems setType automatically clears what set in setData, and setData
> clears that of setType, so I cannot use both to set data and data type at
> the same.

You can also use setDataAndType.

>> What about implicit intents?
>
>
> This looks like an explicit intents, but actually it is implicit. The
> explicit part is just used to invoke the helper activity.
>>
>>
>> As a developer I don't care wether the user wants to use an Android app
>> or webapp.
>
>
> Now the app should return a list of both related web apps and android apps.
> I am sorry I am not fully get what you meant by this statement. What is the
> "user"? Are they the android app developers who use our web intents? Or the
> end user who uses those Android apps?

The user is here the end user of the phone.

I would like to see something like
WebIntentsHelper.chooserDialogWithWebApps (intent)
with the list of both types of apps. The intent should be just like a
normal Android intent.

The end user would have the choice to open an Android app or a web
app. The developer only has to opt-in without caring whether to use a
web intent or Android intent.

Cheers
Friedger

Cheng Zheng

unread,
Jul 28, 2012, 8:11:18 PM7/28/12
to Friedger Müffke, openi...@googlegroups.com
I think I got it now. I will do it and submit asap.

Cheng Zheng

unread,
Jul 29, 2012, 12:06:55 AM7/29/12
to Friedger Müffke, openi...@googlegroups.com
Hi Friedger,

I've changed the interface. Now the procedure of invoking web apps or android apps is as follows:

Intent intent = new Intent(android.content.Intent.ACTION_SEND);                
intent.setType("text/uri-list");                
intent.putExtra(android.content.Intent.EXTRA_TEXT, "http://www.openintents.org");
                
WebIntentsHelper helper = new WebIntentsHelper(OIWebIntentsAndroidSampleAppActivity.this);
                
helper.applicationChooser(intent);

Any android developers who would like to invoke web intents just do what they usually do in Android development and send the intents to our WebIntentsHelper.applicationChooser() method.

Now it is just a very simple sample for ACTION_SEND in github (in order to prove it is feasible). If the interface is ok, I will extend it to more android intent.

Please let me know if there is any problem.

Thanks

Cheng Zheng

Friedger

unread,
Jul 29, 2012, 5:55:37 AM7/29/12
to openi...@googlegroups.com
Hi
Regarding naming in the helper class , i would use createChooserWithWebActivities.

In this particular intent you would probably use SEND_MULTIPLE, and avoid the list mime types.
The approach looks good! Will check the code on Tuesday. Continue in high speed :-)

Friedger

Cheng Zheng <czhe...@gmail.com> wrote:

>Hi Friedger,
>
>I've changed the interface. Now the procedure of invoking web apps or
>android apps is as follows:
>
>Intent intent = new Intent(android.content.Intent.ACTION_SEND);
>
>intent.setType("text/uri-list");
>intent.putExtra(android.content.Intent.EXTRA_TEXT, "
>http://www.openintents.org");
>
>WebIntentsHelper helper = new
>WebIntentsHelper(OIWebIntentsAndroidSampleAppActivity.this);
>
>helper.applicationChooser(intent);
>
>Any android developers who would like to invoke web intents just do what

>they usually do in Android development and send the intents to our *
>WebIntentsHelper.applicationChooser()* method.

>--
>You received this message because you are subscribed to the Google Groups "OpenIntents" group.
>To post to this group, send email to openi...@googlegroups.com.
>To unsubscribe from this group, send email to openintents...@googlegroups.com.
>For more options, visit this group at http://groups.google.com/group/openintents?hl=en.
>

Cheng Zheng

unread,
Jul 30, 2012, 12:42:17 PM7/30/12
to openi...@googlegroups.com
Hi

On Sun, Jul 29, 2012 at 5:55 AM, Friedger <frie...@gmail.com> wrote:
Hi
Regarding naming in the helper class , i would use createChooserWithWebActivities.

In this particular intent you would probably use SEND_MULTIPLE, and avoid the list mime types.
Did you mean "text/*" instead of "text/url-list". But some of the web apps now only support "text/url-list".
BTW, why use SEND_MULTIPLE, do we have to share multiple data?

Friedger Müffke

unread,
Jul 31, 2012, 4:37:54 AM7/31/12
to openi...@googlegroups.com

The Android intent SEND is just for one piece of data. So a mime type of text/* does not make sense here, but something like text/uri if that exists or am I wrong with the assumption that uri-list is for more than one uri.

The Helper should do the mime type conversion/adoption where necessary /possible.

Cheers
Friedger

Cheng Zheng

unread,
Aug 1, 2012, 6:58:58 AM8/1/12
to openi...@googlegroups.com
I think uri-list is for a list of uris. But current service seems to be for sharing ONE uri. Because there is no type like text/uri, I think they use uri-list instead for ONE uri as it is more specific than text/plain.

Friedger Müffke

unread,
Aug 1, 2012, 7:15:58 AM8/1/12
to openi...@googlegroups.com

Yes, the spec says something like that. Hopefully, it does not create too much difficulties as the understanding for sharing of web URLs in the sense of recovery is not really present in Android world. Well, it is used as data and the mime type describes the type of the resolved data and not the type of the data itself.... if that makes sense at all or did I got this wrong?

Do you know an Android app that allows to share bookmarks, e.g.openintents.org?

Friedger

Cheng Zheng

unread,
Aug 2, 2012, 2:37:33 PM8/2/12
to openi...@googlegroups.com
How about AddThis? It is also an active group in webintents community.

Friedger Müffke

unread,
Aug 3, 2012, 4:10:59 AM8/3/12
to openi...@googlegroups.com

They use text/plain in the intents filter :-(
So, I'd suggest to do some kind of mime type translation...
Friedger

Reply all
Reply to author
Forward
0 new messages