0

我如何调用一个意图来启动 Android 操作系统中的原生下载应用程序。我为此搜索了很多,这与我得到的一样接近:

 Intent i = new Intent();
 ComponentName comp = new ComponentName("com.sec.android.providers.downloads","com.sec.android.providers.downloads.DownloadActivity");
 i.setComponent(comp);
 i.setAction("android.intent.action.VIEW");
 self.startActivity(i);

我也试过:

   Intent i = new Intent();
            PackageManager manager = getActivity().getPackageManager();
            i = manager.getLaunchIntentForPackage("com.sec.android.providers.downloads");
            i.addCategory(Intent.CATEGORY_LAUNCHER);
            startActivity(i);

但它给了我一个JavaNullPointerException: i.addCategory(Intent.CATEGORY_LAUNCHER);

4

1 回答 1

0
Intent i = new Intent();  
i.setAction(Intent.ACTION_VIEW);
Uri uri= Uri.fromFile(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS));
i.setData(uri);   
startActivity(i);
于 2013-02-25T12:49:52.223 回答