Example usage for android.content Intent Intent

List of usage examples for android.content Intent Intent

Introduction

In this page you can find the example usage for android.content Intent Intent.

Prototype

protected Intent(Parcel in) 

Source Link

Usage

From source file:Main.java

public static Intent getImageFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.fromFile(file), "image/*");
    return intent;
}

From source file:Main.java

public static void gotoMarket(Activity activity) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://details?id=com.bitime.emoji"));
    activity.startActivity(intent);/* w ww.j  ava  2s .  co m*/
}

From source file:Main.java

private static Intent getPdfFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(file);/*from w w w. j  av  a  2  s  .  co  m*/
    intent.setDataAndType(uri, "application/pdf");
    return intent;
}

From source file:Main.java

private static Intent getPPTFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(file);//  ww w  .j a  va 2 s.c om
    intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
    return intent;
}

From source file:Main.java

public static Intent getImageFileIntent(String param) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "image/*");
    return intent;
}

From source file:Main.java

public static Intent createBaseIntent(String action, String packageName) {
    return new Intent(action).setPackage(packageName);
}

From source file:Main.java

public static void pauseAudioPlayback() {
    Intent i = new Intent("com.android.music.musicservicecommand");
    i.putExtra("command", "pause");
    context.sendBroadcast(i);/*from w  ww. j a v  a  2 s.c  o  m*/
}

From source file:Main.java

private static Intent getWordFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(file);//www . j av a2s . c om
    intent.setDataAndType(uri, "application/msword");
    return intent;
}

From source file:Main.java

private static Intent getTextFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(file);//  w w  w  .  ja v a  2  s  . c  om
    intent.setDataAndType(uri, "text/plain");
    return intent;
}

From source file:Main.java

private static Intent getExcelFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(file);//w  w w  . j  a  v a 2 s  .  c  o m
    intent.setDataAndType(uri, "application/vnd.ms-excel");
    return intent;
}