List of usage examples for android.content Intent ACTION_VIEW
String ACTION_VIEW
To view the source code for android.content Intent ACTION_VIEW.
Click Source Link
From source file:de.cortex_media.phonegap.mediaviewer.MediaViewer.java
private void viewMedia(String url, String type) throws IOException { Uri uri = Uri.parse(url);/*from w w w . j av a 2 s. c om*/ Intent intent = null; if (url.contains(ASSETS)) { String filepath = url.replace(ASSETS, ""); String filename = filepath.substring(filepath.lastIndexOf("/") + 1, filepath.length()); File fp = new File(this.cordova.getActivity().getFilesDir() + "/" + filename); if (!fp.exists()) { this.copy(filepath, filename); } uri = Uri.parse("file://" + this.cordova.getActivity().getFilesDir() + "/" + filename); intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, type); // use for type: // "video/*" // application/pdf } else { // Display video player intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, type); } this.cordova.getActivity().startActivity(intent); }
From source file:com.zjut.material_wecenter.controller.fragment.SettingsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // ?//from w ww. ja va 2 s .c o m Preference version = findPreference("version"); version.setSummary(BuildConfig.VERSION_NAME); // GitHub? Preference github = findPreference("github"); github.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(getString(R.string.github_url))); startActivity(intent); return false; } }); // new CheckForUpdate().execute(); }
From source file:com.target.plugins.PdfViewer.java
public String showPdf(String fileName) { File file = new File(fileName); if (file.exists()) { try {/* w ww . j ava 2 s .c om*/ Uri path = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(path, "application/pdf"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //intent.setData(Uri.parse(fileName)); this.ctx.startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { System.out.println("PdfViewer: Error loading url " + fileName + ":" + e.toString()); return e.toString(); } } else { return "file not found"; } }
From source file:com.phonegap.plugins.ExternalAppLauncher.ExternalAppLauncher.java
/** * launch market to certain app//from w ww . j av a 2s . c om */ private boolean launchMarket(Context context, String packageName) { Log.d(pluginName, "Launch Market"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + packageName)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Boolean result = false; try { context.startActivity(intent); result = true; } catch (Exception ex) { Log.d(pluginName, ex.getMessage()); result = false; } return result; }
From source file:com.arellomobile.android.push.PushGCMIntentService.java
private static void generateNotification(Context context, Intent intent, Handler handler) { Bundle extras = intent.getExtras();// w w w . jav a 2 s.co m if (extras == null) { return; } extras.putBoolean("foregroud", GeneralUtils.isAppOnForeground(context)); String title = (String) extras.get("title"); String link = (String) extras.get("l"); // empty message with no data Intent notifyIntent; if (link != null) { // we want main app class to be launched notifyIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link)); notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } else { notifyIntent = new Intent(context, PushHandlerActivity.class); notifyIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); // pass all bundle notifyIntent.putExtra("pushBundle", extras); } // first string will appear on the status bar once when message is added CharSequence appName = context.getPackageManager().getApplicationLabel(context.getApplicationInfo()); if (null == appName) { appName = ""; } NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationFactory notificationFactory; //is this banner notification? String bannerUrl = (String) extras.get("b"); //also check that notification layout has been placed in layout folder int layoutId = context.getResources().getIdentifier(BannerNotificationFactory.sNotificationLayout, "layout", context.getPackageName()); if (layoutId != 0 && bannerUrl != null) { notificationFactory = new BannerNotificationFactory(context, extras, appName.toString(), title, PushManager.sSoundType, PushManager.sVibrateType); } else { notificationFactory = new SimpleNotificationFactory(context, extras, appName.toString(), title, PushManager.sSoundType, PushManager.sVibrateType); } notificationFactory.generateNotification(); notificationFactory.addSoundAndVibrate(); notificationFactory.addCancel(); Notification notification = notificationFactory.getNotification(); notification.contentIntent = PendingIntent.getActivity(context, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); if (mSimpleNotification) { manager.notify(PushManager.MESSAGE_ID, notification); } else { manager.notify(PushManager.MESSAGE_ID++, notification); } generateBroadcast(context, extras); }
From source file:edu.stanford.mobisocial.dungbeetle.model.Feed.java
public static void view(Activity foreground, Uri feedUri) { Log.d("MMSSBB", "viewing " + feedUri); Intent launch = new Intent(Intent.ACTION_VIEW); launch.setDataAndType(feedUri, MIME_TYPE); foreground.startActivity(launch);//from w ww.ja v a 2 s. c om }
From source file:com.phonegap.plugins.pdfViewer.PdfViewer.java
public String showPdf(String fileName) { File file = new File(fileName); if (file.exists()) { try {/* w w w. j a v a 2 s . co m*/ Uri path = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(path, "application/pdf"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //intent.setData(Uri.parse(fileName)); this.ctx.startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { System.out.println("PdfViewer: Error loading url " + fileName + ":" + e.toString()); return e.toString(); } } else { return "file not found"; } }
From source file:piramide.multimodal.client.tester.ApplicationDownloader.java
void install() { final Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(//w w w .j a v a 2s. c om Uri.parse("file://" + this.activity.getFilesDir().getAbsolutePath() + "/" + APK_FILENAME), "application/vnd.android.package-archive"); this.activity.startActivity(intent); }
From source file:com.jumpbyte.mobile.plugin.PdfViewer.java
public String showPdf(String fileName) { File file = new File(fileName); Log.i("PdfViewer", "open file " + fileName); // if (file.exists()) { Log.i("PdfViewer", "file exist"); try {/*from w w w. j av a2s .c o m*/ Uri path = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(path, "application/pdf"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //intent.setData(Uri.parse(fileName)); this.ctx.startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { System.out.println("PdfViewer: Error loading url " + fileName + ":" + e.toString()); return e.toString(); } /* }else{ Log.i("PdfViewer", "file not exist"); return "file not found"; } */ }
From source file:ee.ria.DigiDoc.activity.OpenExternalFileActivity.java
private void handleIntentAction() { Intent intent = getIntent();//from ww w . j a v a 2 s . c o m ContainerFacade container = null; Timber.d("Handling action: %s ", intent.getAction()); switch (intent.getAction()) { case Intent.ACTION_VIEW: try { container = createContainer(intent.getData()); } catch (Exception e) { Timber.e(e, "Error creating container from uri %s", intent.getData().toString()); } break; case Intent.ACTION_SEND: Uri sendUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (sendUri != null) { container = createContainer(sendUri); } break; case Intent.ACTION_SEND_MULTIPLE: ArrayList<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (uris != null) { container = createContainer(uris); } break; } if (container != null) { createContainerDetailsFragment(container); } else { createErrorFragment(); } }