Example usage for android.content Intent ACTION_VIEW

List of usage examples for android.content Intent ACTION_VIEW

Introduction

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

Prototype

String ACTION_VIEW

To view the source code for android.content Intent ACTION_VIEW.

Click Source Link

Document

Activity Action: Display the data to the user.

Usage

From source file:Main.java

public static Intent buildIntentForKushikatsuInstall() {
    final Uri uri = Uri.parse("market://details?id=" + PACKAGE_NAME);
    final Intent i = new Intent(Intent.ACTION_VIEW, uri);
    return i;/*from  w  w  w.j  a  v a2s.c  om*/
}

From source file:net.reichholf.dreamdroid.intents.IntentFactory.java

/**
 * @param event/*from  ww w  .j a v  a  2  s.co  m*/
 */
public static void queryIMDb(Context context, ExtendedHashMap event) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    String uriString = "imdb:///find?q=" + event.getString(Event.KEY_EVENT_TITLE);
    intent.setData(Uri.parse(uriString));
    try {
        context.startActivity(intent);
    } catch (ActivityNotFoundException anfex) {
        if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("mobile_imdb", false)) {
            uriString = "http://m.imdb.com/find?q=" + event.getString(Event.KEY_EVENT_TITLE);
        } else {
            uriString = "http://www.imdb.com/find?q=" + event.getString(Event.KEY_EVENT_TITLE);
        }
        intent.setData(Uri.parse(uriString));
        context.startActivity(intent);
    }
}

From source file:Main.java

/**
 * @deprecated/*from  ww w .j  a va  2s. c o m*/
 * use isGooglePlayInstalled(Context ctx) instead
 * @param ctx
 * @return
 */
public static boolean isAndroidMarketInstalled(Context ctx) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://search?q=foo"));
    PackageManager pm = ctx.getPackageManager();
    List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
    if (list.size() > 0) {
        return true;
    } else {
        return false;
    }
}

From source file:Main.java

/**
 * Launch this app store site./*from w w w . j  a va 2 s. com*/
 *
 * @param context Context
 */
public static void launchStore(Context context) {
    try {
        context.startActivity(
                new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())));
    } catch (ActivityNotFoundException e) {
        Log.w(TAG, "Occurred ActivityNotFoundException.", e);
    }
}

From source file:Main.java

/**
 * Creates an Intent to open the Parche application without a discount, but indicating what app the request
 * is coming from./*from  ww w .  ja  va  2  s.  c  om*/
 *
 * @param aContext  The current context.
 * @param aAPIKey   The partner application's Parche API key.
 *
 * @return The intent to open the Parche application, or null if the app needs to be updated or installed.
 */
public static Intent openParcheIntent(Context aContext, String aAPIKey) {
    Intent returnIntent = null;
    if (!parcheNeedsToBeUpdatedOrInstalled(aContext)) {
        String urlString = URL_SCHEME + OPEN_ENDPOINT + String.format(NO_DISCOUNT_FORMAT, aAPIKey);
        returnIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlString));
    }

    return returnIntent;
}

From source file:Main.java

public static boolean installFromMarket(Activity activity, String pkg) {
    try {//from w  w w . j a va2 s  . c o  m
        activity.startActivity(new Intent(Intent.ACTION_VIEW, marketUri(pkg)));
        return true;
    } catch (ActivityNotFoundException e) {
        return false;
    }
}

From source file:Main.java

public static AlertDialog showDownloadDialog(final Context ctx) {
    AlertDialog.Builder downloadDialog = new AlertDialog.Builder(ctx);
    downloadDialog.setTitle("Layar is not available");
    downloadDialog.setMessage("Do you want to download it from the market?");
    downloadDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

        @Override// w ww .j  av a  2 s  .  c  om
        public void onClick(DialogInterface dialogInterface, int i) {
            Uri uri = Uri.parse("market://details?id=com.layar");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            try {
                ctx.startActivity(intent);
            } catch (ActivityNotFoundException anfe) {
                Toast.makeText(ctx, "Market not installed", Toast.LENGTH_SHORT).show();
            }
        }

    });

    downloadDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
        }

    });

    return downloadDialog.show();
}

From source file:Main.java

/**
 * Creates an intent for viewing a url in a browser
 *
 * @param context//from   ww  w.j  a v  a  2  s.c  om
 * @return
 */
public static Intent getBrowserIntent(Context context, String url) {
    if (TextUtils.isEmpty(url))
        throw new IllegalArgumentException("url cannot be empty or null");
    return new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url));
}

From source file:Main.java

/**
 * Used to search the Play Store for a specific app.
 * /*from   w w w.java 2 s  .  com*/
 * @param context The {@link Context} to use.
 * @param themeName The theme name to search for.
 */
public static void openAppPage(final Context context, final String themeName) {
    final Intent shopIntent = new Intent(Intent.ACTION_VIEW);
    shopIntent.setData(Uri.parse(APP_URI + themeName));
    shopIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    shopIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    context.startActivity(shopIntent);
}

From source file:Main.java

public static void openURL(Context ctx, String url) {
    Intent i2 = new Intent(Intent.ACTION_VIEW);
    i2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i2.setData(Uri.parse(url));/*from  ww  w . j  a v a2 s . co m*/
    ctx.startActivity(i2);
}