Pregunta

I am attempting to make a demonstration script that control's an android tablet. At one point I run the following command to open a PDF file:

am start -a android.intent.action.VIEW -d file:///mnt/sdcard/Demos/File.pdf -t "application/pdf"

and when this command is ran a popup is displayed asking me to choose the default application to open this type of file. I can check "use by default for this action" and it will never pop up again. I want to know where these "Launch by default" settings are actually saved (a file in the system directory maybe?) so I can simply push the needed file/files onto another tablet and never have that popup occur. The tablets I am using are running gingerbread and I have complete root access.

¿Fue útil?

Solución

I would recommend against circumventing the Android user-controls and app defaults, and simply direct the Activity Manager to use your specific PDF viewer, by specifying the component name:

am start 
    -a android.intent.action.VIEW 
    -n com.package.name/com.package.name.ActivityName 
    -d file:///mnt/sdcard/Demos/File.pdf 
    -t "application/pdf"

Note the -n switch. This needs to be your preferred viewer's package and Activity name. The shortened version can also be used, such that -n com.package.name/.ActivityName. (Thank you Rajesh).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top