startActivity on "file://" links crashes

Put your problem here if it does not fit any of the other categories.

startActivity on "file://" links crashes

Postby POMATu » Tue Apr 12, 2011 5:45 pm

Hi. I am trying to create program that simply opens file on sdcard. I tried opening mp3, mp4, and apk - the code bellow always crashes unexpectedly.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.          String _path = "file:///sdcard/1.apk";
  2.        
  3.          Uri outputFileUri = Uri.parse(_path);
  4.         Intent intent = new Intent();
  5.         intent.setAction(Intent.ACTION_VIEW);
  6.         intent.setData(outputFileUri);  
  7.        
  8.           startActivity(intent);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Market links also crashes. But when I set _path="http://google.com" - browser opens normally. How can I make this code work?
POMATu
Freshman
Freshman
 
Posts: 2
Joined: Tue Apr 12, 2011 5:39 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot], MSNbot Media and 37 guests