开发者

Possible to invoke system's USB mode activity from within an application?

Normally a user would have to go to the notification bar -> click "Select to copy files to/from your computer" and then be presented with the activity offering mount/unmount/etc. options. Can anyone share their experience trying to open this from an application?

It appears one guy found a way to open this fr开发者_如何学JAVAom within an application here, but only for an HTC phone. Any idea how I could find out what that activity might be for other devices as well?

EDIT: See Comments below; it appears it may be device independent, and the full name of the class is com.android.server.status.UsbStorageActivity


Unfortunately, it appears only the system can open this dialog.

I attempted to launch UsbStorageActivity with

    Intent intent = new Intent();
    intent.setClassName("android", "com.android.server.status.UsbStorageActivity");
    getContext().startActivity(intent);

But got the following exception:

03-21 09:13:55.653: WARN/ActivityManager(2491): Permission denied: checkComponentPermission() reqUid=1000
03-21 09:13:55.653: WARN/ActivityManager(2491): Permission Denial: starting Intent { cmp=android/com.android.server.status.UsbStorageActivity } from ProcessRecord{47d615c8 3399:com.saltillo.chatpc/10080} (pid=3399, uid=10080) requires null
03-21 09:13:55.657: DEBUG/AndroidRuntime(3399): Shutting down VM
03-21 09:13:55.657: WARN/dalvikvm(3399): threadid=1: thread exiting with uncaught exception (group=0x4001d7d0)
03-21 09:13:55.665: ERROR/AndroidRuntime(3399): FATAL EXCEPTION: main
03-21 09:13:55.665: ERROR/AndroidRuntime(3399): java.lang.SecurityException: Permission Denial: starting Intent { cmp=android/com.android.server.status.UsbStorageActivity } from ProcessRecord{47d615c8 3399:com.saltillo.chatpc/10080} (pid=3399, uid=10080) requires null

Which I interpret to mean this process cannot be launched without sharing the system uid. Which as far as I know is impossible. Otherwise, someone please correct me!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜