[android-developers] Launch activity on a file with certain name pattern (file-manager independent)

2011-04-07 Thread Dmitry Golubovsky
Hi,

Suppose I have a number files whose names satisfy certain pattern,
located anywhere in the file system (SD card likely).

I am looking for a file-manager independent way to launch a predefined
target activity upon user tapping on those files icons provided that
the activity has proper intent filter configured in its manifest xml.

For example, file name pattern is *.image, and the target application
has in its manifest:

intent-filter
  action android:name=android.intent.action.PICK /
  action android:name=android.intent.action.VIEW /
  category android:name=android.intent.category.DEFAULT /
  category android:name=android.intent.category.BROWSABLE /
  data android:scheme=file android:mimeType=*/* android:host=*
android:pathPattern=.*\\.image /
/intent-filter

I am hoping that the intent filter definition is correct (based on
examples found in many places)

Unfortunately several file managers I tried (ES, Linda, AndExplorer,
etc.) do not seem to honor this, and try to open a *.image file in
their own way (that is in most cases say they just say cannot open
it). And in fact I think it is not a good idea to require installation
of some application just to launch activities on files.

How else could it be done regardless of file manager?

Ideally it would be an icon for each file on the home screen. Tapping
on such an icon launches the target activity.

Do I have to create a fake wrapper application for each file? Or is
there a standardized/programmatic way to place a file shortcut icon on
the home screen without third party app installations?

The intended usage scenario: Squeak VM executable is packaged as an
application on its own. Smalltalk images + changes + sources are
distributed separately, and may come into the device in various ways
(e. g. transferred via USB).

If creation of a fake wrapper application is the only way, can an
application delete its assets after installation is complete? I can
see possible logic for such an application to have the files packed in
assets, and when installed, files are copied from assets to sdcard.
Assets are no longer needed, and just waste the storage space.

A wrapper application code is basically boilerplate; are there any
automated tools to generate it?

Any suggestions?

Thanks.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Launch activity on a file with certain name pattern (file-manager independent)

2011-04-07 Thread Dianne Hackborn
Use adb logcat to look at the Intent the programs you are interacting with
are trying to start.  The platform does not allow the user to tap on
arbitrary files with unknown MIME types on the SD card, so there is no
standard convention for this.

For icons on the home screen, you can have an activity that allows the user
to pick a shortcut (like the settings shortcuts etc) that would build an
Intent that launches your specific activity with the data set to the file it
should use.  For that case your activity doesn't need any intent filters,
since the shortcut points directly to it.

On Thu, Apr 7, 2011 at 7:17 AM, Dmitry Golubovsky golubov...@gmail.comwrote:

 Hi,

 Suppose I have a number files whose names satisfy certain pattern,
 located anywhere in the file system (SD card likely).

 I am looking for a file-manager independent way to launch a predefined
 target activity upon user tapping on those files icons provided that
 the activity has proper intent filter configured in its manifest xml.

 For example, file name pattern is *.image, and the target application
 has in its manifest:

 intent-filter
  action android:name=android.intent.action.PICK /
  action android:name=android.intent.action.VIEW /
  category android:name=android.intent.category.DEFAULT /
  category android:name=android.intent.category.BROWSABLE /
  data android:scheme=file android:mimeType=*/* android:host=*
 android:pathPattern=.*\\.image /
 /intent-filter

 I am hoping that the intent filter definition is correct (based on
 examples found in many places)

 Unfortunately several file managers I tried (ES, Linda, AndExplorer,
 etc.) do not seem to honor this, and try to open a *.image file in
 their own way (that is in most cases say they just say cannot open
 it). And in fact I think it is not a good idea to require installation
 of some application just to launch activities on files.

 How else could it be done regardless of file manager?

 Ideally it would be an icon for each file on the home screen. Tapping
 on such an icon launches the target activity.

 Do I have to create a fake wrapper application for each file? Or is
 there a standardized/programmatic way to place a file shortcut icon on
 the home screen without third party app installations?

 The intended usage scenario: Squeak VM executable is packaged as an
 application on its own. Smalltalk images + changes + sources are
 distributed separately, and may come into the device in various ways
 (e. g. transferred via USB).

 If creation of a fake wrapper application is the only way, can an
 application delete its assets after installation is complete? I can
 see possible logic for such an application to have the files packed in
 assets, and when installed, files are copied from assets to sdcard.
 Assets are no longer needed, and just waste the storage space.

 A wrapper application code is basically boilerplate; are there any
 automated tools to generate it?

 Any suggestions?

 Thanks.

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en