如果程序安装在内存中,设置android.intent.action.BOOT_COMPLETED后即可开机启动,但程序移至sd卡便无法开机启动了,请问是否可以做到sd中的程序如何开机启动

解决方案 »

  1.   

    是不是 android 限制了 无法实现的啊
      

  2.   

    应该是没有问题的!
    只要程序中注册android.intent.action.BOOT_COMPLETED到系统,就能实现开机启动啊可能是其它方面的问题吧看看程序有没有访问SDcard的权限等等其它的问题楼主再看看吧!
      

  3.   

    不知楼上的实践过sd卡上的开机启动不,360装在sd卡上,开机启动的流量监控也起不了的
      

  4.   

    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) 
    {   
      /*SD卡可用 正常操作*/          
    }else {   
      /*SD不可用 延时重新检查SD卡可不可用  重复几次 直到SD卡可用 */;
    }
      

  5.   

    你可以判断SDCard是否已经挂载,如果挂载成功再启动你的程序。
    即提供一个监听方法BroadcastReceiver 设置IntentFilter为:
    Intent.ACTION_MEDIA_MOUNTED
    Intent.ACTION_MEDIA_EJECT
    Intent.ACTION_MEDIA_REMOVED 
    然后再public void onReceive(Context context, Intent intent) 中实现你的启动逻辑startActivity网上别人的代码,参考:
    private final BroadcastReceiver broadcastRec = new BroadcastReceiver() {  @Override  public void onReceive(Context context, Intent intent) {  if(intent.getAction().equals("android.intent.action.MEDIA_MOUNTED"))//SD 卡已经成功挂载  {  imagepath = android.os.Environment.getExternalStorageDirectory();//你的SD卡路径  }else if(intent.getAction().equals("android.intent.action.MEDIA_REMOVED")//各种未挂载状态  ||intent.getAction().equals("android.intent.action.ACTION_MEDIA_UNMOUNTED")  ||intent.getAction().equals("android.intent.action.ACTION_MEDIA_BAD_REMOVAL"))  {  imagepath = android.os.Environment.getDataDirectory();//你的本地路径  }  }  };  //在IntentFilter中选择你要监听的行为  IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED);  intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);  intentFilter.addAction(Intent.ACTION_MEDIA_REMOVED);  //intentFilter.addAction(Intent.ACTION_MEDIA_SHARED);  intentFilter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);  //intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);  //intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);  intentFilter.addDataScheme("file");  registerReceiver(broadcastRec, intentFilter);//注册监听函数  unregisterReceiver(broadcastRec);//使用完注销广播监听函数
      

  6.   

    如果程序安装在内部存储中,设置android.intent.action.BOOT_COMPLETED后即可开机启动。你把程序的什么格式放在sd卡中? 就是你所说的把程序移至SD中的操作是具体怎么做的?目前我可以想到的就是写脚本将sd卡中的程序资源安装上。 
      

  7.   

    “把程序移至SD中的操作是具体怎么做的”
    一种方式 直接用91安装到sd卡上
    另一种方式 可以用系统的移至sd卡
      

  8.   

    App Install Location
    Broadcast Receivers listening for "boot completed" 
    The system delivers the ACTION_BOOT_COMPLETED broadcast before the external storage is mounted to the device. If your application is installed on the external storage, it can never receive this broadcast. 
    http://www.ideasandroid.com/android/sdk/docs/guide/appendix/install-location.html
    android明确说明了,安装在sd卡上的应用程序是接收不到ACTION_BOOT_COMPLETED消息的,在mount sd卡之前这个消息已经发出了。
      

  9.   


    你根本就没有理解楼主的意思,和sd卡有没有挂载有什么关系。应用装在外置sd中是无法收到那个广播的。