9
私のアプリケーションは大きなzipファイル(100MB以上)をダウンロードします。私はデフォルトのDownloadManagerを使用してダウンロードを容易にしています。 Google APIのドキュメントでは、BroadcastReceiverを登録し、ACTION_NOTIFICATION_CLICKEDをリッスンすることを提案しています。私はそれをやっているが、私はBroadcastReceiver内からDownloadManagerを呼び出す方法を知りません。ブロードキャストレシーバからダウンロードマネージャを起動するには?
私がしたいことは、基本的にブラウザが行うことです。ブラウザがファイルをダウンロードし、ユーザーがDownloadManager通知をクリックするとDownloadManagerウィンドウがポップアップします。これを達成するために私はどのような意図を持っていますか?
マイコード:私自身の答えを見つけ
<receiver android:name="com.test.receiver.DownloadReceiver">
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"></action>
<action android:name="android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED" />
</intent-filter>
</receiver>
public class DownloadReceiver extends BroadcastReceiver {
private static final String tag = DownloadReceiver.class.getSimpleName();
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
*** code for unzipping removed ***
}
else if (DownloadManager.ACTION_NOTIFICATION_CLICKED.equals(action)) {
// Open the download manager
// BUT HOW???
}