List of usage examples for android.app DownloadManager COLUMN_LOCAL_URI
String COLUMN_LOCAL_URI
To view the source code for android.app DownloadManager COLUMN_LOCAL_URI.
Click Source Link
From source file:org.crossconnect.bible.activity.main.ResourceFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); resourceService = ((MainActivity) getActivity()).getResourceService(); // Prepare the loader. Either re-connect with an existing one, // or start a new one. Bundle bundle = new Bundle(); bundle.putParcelable("BibleText", Utils.loadBibleText(getActivity().getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE))); getLoaderManager().initLoader(0, bundle, this); // Create an empty adapter we will use to display the loaded data. mAdapter = new ResourceListAdapter(getActivity()); setListAdapter(mAdapter);// ww w .ja v a 2 s .c o m dm = ((DownloadManager) getActivity().getSystemService("download")); BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) { long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); Query query = new Query(); query.setFilterById(enqueue); Cursor c = dm.query(query); if (c.moveToFirst()) { int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS); if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) { String uriString = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)); } } String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getActivity() .getSystemService(ns); int icon = R.drawable.icon_book_rss; CharSequence tickerText = "Resource Download Complete"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); CharSequence contentTitle = "Download Complete"; CharSequence contentText = "Click to view downloaded resources"; Intent notificationIntent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //uncomment when better // Intent notificationIntent = new Intent(getActivity(), MusicActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(getActivity(), 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; int HELLO_ID = 1; mNotificationManager.notify(HELLO_ID, notification); } } }; getActivity().registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); }
From source file:net.momodalo.app.vimtouch.VimTouch.java
private void downloadFullRuntime() { BroadcastReceiver receiver = new BroadcastReceiver() { @Override//from ww w . j a v a2 s .com public void onReceive(Context context, Intent intent) { context.unregisterReceiver(this); String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) { long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); Query query = new Query(); query.setFilterById(mEnqueue); Cursor c = mDM.query(query); if (c.moveToFirst()) { int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS); if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) { String uriString = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)); Intent newintent = new Intent(getApplicationContext(), InstallProgress.class); newintent.setData(Uri.parse(uriString)); startActivity(newintent); } } } } }; registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); mDM = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); Request request = new Request(Uri.parse("https://github.com/downloads/momodalo/vimtouch/vim.vrz")); mEnqueue = mDM.enqueue(request); }