launching Android Native application

All your problems with Audio, Video and Images.

launching Android Native application

Postby alexsh » Fri Jan 02, 2009 3:02 pm

Hi

I am trying to accomplish the following: given some media file i have i would like to launch one of the native Android apps such as Music and make them to display/play the file.
I could open the android browser with a url I need the following way:

Intent i = new Intent();
ComponentName comp =
new ComponentName("com.android.browser", "com.android.browser.BrowserActivity");
i.setComponent(comp);
i.setAction("android.intent.action.VIEW");
i.addCategory("android.intent.category.BROWSABLE");
Uri uri = Uri.parse("http://groups.google.com/group/clickin-2-da-beat/files");
i.setData(uri);
self.startActivity(i);


Here I use the activity from the browser app to start it.
I would like to do the same with other activities as well, but I dont know which one.....

Thanks for the help
alexsh
Freshman
Freshman
 
Posts: 3
Joined: Fri Jan 02, 2009 2:57 pm

Top

Postby MrSnowflake » Fri Jan 02, 2009 4:16 pm

The idea is good, but you have it too complex. For starting the browser you should use:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Intent i = new Intent(Intent.ACTION_VIEW);
  2. Uri u = Uri.parse("http://www.openintents.org");
  3. i.setData(u);
  4. startActivity(i);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
And this is for the default mediaplayer:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Intent i = new Intent(Intent.ACTION_VIEW);
  2. Uri u = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
  3. i.setData(u);
  4. startActivity(i);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Take a look at the OpenIntents.org intent list.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby alexsh » Sat Jan 03, 2009 9:02 am

Hi

Thanks for the reply. The browser thing works OK.
But the opening image code snippet gives me this exception:
No Activity found to handle Intent { action=android.intent.action.VIEW data=content://media/internal/audio/media/content://data/images.jpg }

this is the code I used:

Intent i = new Intent(Intent.ACTION_VIEW);
Uri u = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "content://data/images.jpg");
i.setData(u);
startActivity(i);
alexsh
Freshman
Freshman
 
Posts: 3
Joined: Fri Jan 02, 2009 2:57 pm

Postby alexsh » Sat Jan 03, 2009 9:40 am

Hi

I have found out that I need to set the mimetype

In this way:

Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File(<my file>);
intent.setDataAndType(Uri.fromFile(file), <mimetype>);
startActivity(intent);

Using mp3 and "audio/*" mimetype it works OK
for jpg and "image/*" I get:


E/AndroidRuntime( 414): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.android.camera/com.android.camera.View
Image}: java.lang.IllegalAccessException: access to class not allowed
E/AndroidRuntime( 414): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2068)
...

I guess I need to know which applications are assigned to each mimetype and how can I change their permission.
alexsh
Freshman
Freshman
 
Posts: 3
Joined: Fri Jan 02, 2009 2:57 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 6 guests