Example usage for android.provider Browser EXTRA_APPLICATION_ID

List of usage examples for android.provider Browser EXTRA_APPLICATION_ID

Introduction

In this page you can find the example usage for android.provider Browser EXTRA_APPLICATION_ID.

Prototype

String EXTRA_APPLICATION_ID

To view the source code for android.provider Browser EXTRA_APPLICATION_ID.

Click Source Link

Document

The name of the extra data when starting the Browser from another application.

Usage

From source file:org.wso2.emm.agent.api.ApplicationManager.java

/**
 * Creates a webclip on the device home screen.
 * @param url   - URL should be passed in as a String.
 * @param title - Title(Web app title) should be passed in as a String.
 */// www  .j  a v  a2  s.  c  o  m
public void manageWebAppBookmark(String url, String title, String operationType) throws AndroidAgentException {
    final Intent bookmarkIntent = new Intent();
    final Intent actionIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    long urlHash = url.hashCode();
    long uniqueId = (urlHash << MAX_URL_HASH) | actionIntent.hashCode();

    actionIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId));
    bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, actionIntent);
    bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
    bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
            Intent.ShortcutIconResource.fromContext(context, R.drawable.ic_bookmark));
    if (operationType != null) {
        if (resources.getString(R.string.operation_install).equalsIgnoreCase(operationType)) {
            bookmarkIntent.setAction(resources.getString(R.string.application_package_launcher_install_action));
        } else if (resources.getString(R.string.operation_uninstall).equalsIgnoreCase(operationType)) {
            bookmarkIntent
                    .setAction(resources.getString(R.string.application_package_launcher_uninstall_action));
        } else {
            throw new AndroidAgentException("Cannot create webclip due to invalid operation type.");
        }
    } else {
        bookmarkIntent.setAction(resources.getString(R.string.application_package_launcher_install_action));
    }
    context.sendBroadcast(bookmarkIntent);
}

From source file:com.mediatek.mms.ext.DefaultMmsConfigExt.java

public void openUrl(Context context, String url) {
    Log.d(TAG, "openUrl, url=" + url);
    Uri theUri = Uri.parse(url);//from  ww  w .  ja va  2 s.  c  o  m
    Intent intent = new Intent(Intent.ACTION_VIEW, theUri);
    intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    context.startActivity(intent);
}

From source file:org.wso2.app.catalog.api.ApplicationManager.java

/**
 * Creates a webclip on the device home screen.
 *
 * @param url   - URL should be passed in as a String.
 * @param title - Title(Web app title) should be passed in as a String.
 */// ww  w.j a v a  2s .  c  o m
public void manageWebAppBookmark(String url, String title, String operationType) throws AppCatalogException {
    final Intent bookmarkIntent = new Intent();
    final Intent actionIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    long urlHash = url.hashCode();
    long uniqueId = (urlHash << MAX_URL_HASH) | actionIntent.hashCode();

    actionIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId));
    bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, actionIntent);
    bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
    bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
            Intent.ShortcutIconResource.fromContext(context, R.drawable.ic_bookmark));
    if (operationType != null) {
        if (resources.getString(R.string.operation_install).equalsIgnoreCase(operationType)) {
            bookmarkIntent.setAction(resources.getString(R.string.application_package_launcher_install_action));
        } else if (resources.getString(R.string.operation_uninstall).equalsIgnoreCase(operationType)) {
            bookmarkIntent
                    .setAction(resources.getString(R.string.application_package_launcher_uninstall_action));
        } else {
            throw new AppCatalogException("Cannot create webclip due to invalid operation type.");
        }
    } else {
        bookmarkIntent.setAction(resources.getString(R.string.application_package_launcher_install_action));
    }
    context.sendBroadcast(bookmarkIntent);
}

From source file:de.persoapp.android.core.adapter.MainViewFragment.java

protected void sendIntentToBrowser() {
    if (mRefreshAddress != null) {
        final Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(mRefreshAddress));

        // use this to reuse the last tab in the browser
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, "com.android.browser");
        try {//from ww w .  j a  va2 s .  c o  m
            Cat.d("RefreshAddress == %b, %s", mRefreshAddress.endsWith("Major=ok"), mRefreshAddress);

            startActivity(intent);
        } catch (final Exception e) {
            Cat.w(e, "Unexpected exception");
        }
    }
}

From source file:org.smssecure.smssecure.ConversationActivity.java

@Override
public void startActivity(Intent intent) {
    try {// w ww.j  a v  a 2  s  . co  m
        if (intent.getStringExtra(Browser.EXTRA_APPLICATION_ID) != null) {
            intent.removeExtra(Browser.EXTRA_APPLICATION_ID);
        }
        super.startActivity(intent);
        Log.d(TAG, "Opened link: " + intent.getDataString());
    } catch (ActivityNotFoundException anfe) {
        Log.w(TAG, "No app found to view the link '" + intent.getDataString() + "', ignoring...");
        Toast.makeText(this, R.string.ConversationActivity_cant_open_link, Toast.LENGTH_SHORT).show();
    }
}

From source file:org.peterbaldwin.vlcremote.app.PlaybackActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_preferences:
        pickServer();//from   w  ww.  jav  a  2 s  . c  om
        return true;
    case R.id.menu_help:
        Intent intent = new Intent(Intent.ACTION_VIEW, URI_TROUBLESHOOTING);
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName());
        startActivity(intent);
        return true;
    case R.id.menu_action_button_first:
        Buttons.sendCommand(mMediaServer, this, Preferences.KEY_BUTTON_FIRST);
        return true;
    case R.id.menu_action_button_second:
        Buttons.sendCommand(mMediaServer, this, Preferences.KEY_BUTTON_SECOND);
        return true;
    case R.id.menu_action_button_third:
        Buttons.sendCommand(mMediaServer, this, Preferences.KEY_BUTTON_THIRD);
        return true;
    case R.id.menu_action_button_fourth:
        Buttons.sendCommand(mMediaServer, this, Preferences.KEY_BUTTON_FOURTH);
        return true;
    case R.id.menu_action_button_fifth:
        Buttons.sendCommand(mMediaServer, this, Preferences.KEY_BUTTON_FIFTH);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.jamiealtizer.cordova.inappbrowser.InAppBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url           The url to load.
 * @param usePhoneGap   Load url in PhoneGap webview
 * @return              "" if ok, or error message.
 *//*from   www  .  ja v a 2s .com*/
public String openExternal(String url) {
    try {
        Intent intent = null;
        intent = new Intent(Intent.ACTION_VIEW);
        // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
        // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
        Uri uri = Uri.parse(url);
        if ("file".equals(uri.getScheme())) {
            intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri));
        } else {
            intent.setData(uri);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName());
        this.cordova.getActivity().startActivity(intent);
        return "";
    } catch (android.content.ActivityNotFoundException e) {
        Log.d(LOG_TAG, "InAppBrowser: Error loading url " + url + ":" + e.toString());
        return e.toString();
    }
}

From source file:com.initialxy.cordova.themeablebrowser.ThemeableBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url/*w  w  w  . jav a  2  s . co m*/
 * @return
 */
public String openExternal(String url) {
    try {
        Intent intent = null;
        intent = new Intent(Intent.ACTION_VIEW);
        // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
        // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
        Uri uri = Uri.parse(url);
        if ("file".equals(uri.getScheme())) {
            intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri));
        } else {
            intent.setData(uri);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName());
        this.cordova.getActivity().startActivity(intent);
        return "";
    } catch (android.content.ActivityNotFoundException e) {
        Log.d(LOG_TAG, "ThemeableBrowser: Error loading url " + url + ":" + e.toString());
        return e.toString();
    }
}

From source file:org.chromium.chrome.browser.download.OMADownloadHandler.java

/**
 * Shows a dialog to ask whether user wants to open the nextURL.
 *
 * @param omaInfo Information about the OMA content.
 *//*  w ww.j a v  a2 s .com*/
private void showNextUrlDialog(OMAInfo omaInfo) {
    if (omaInfo.isValueEmpty(OMA_NEXT_URL)) {
        return;
    }
    final String nextUrl = omaInfo.getValue(OMA_NEXT_URL);
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.next_url_post_oma_download, null);
    TextView textView = (TextView) v.findViewById(R.id.oma_download_next_url);
    textView.setText(nextUrl);
    final Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(nextUrl));
                intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName());
                intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
                intent.setPackage(mContext.getPackageName());
                activity.startActivity(intent);
            }
        }
    };
    new AlertDialog.Builder(activity).setTitle(R.string.open_url_post_oma_download)
            .setPositiveButton(R.string.ok, clickListener).setNegativeButton(R.string.cancel, clickListener)
            .setView(v).setCancelable(false).show();
}