Example usage for android.content Intent setData

List of usage examples for android.content Intent setData

Introduction

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

Prototype

public @NonNull Intent setData(@Nullable Uri data) 

Source Link

Document

Set the data this intent is operating on.

Usage

From source file:cc.metapro.openct.allclasses.ExcelDialog.java

@NonNull
@Override//from w ww.jav a2 s.  c o  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.import_from_excel)
            .setMessage(R.string.select_file_tip).setPositiveButton(R.string.select_file, null)
            .setNegativeButton(android.R.string.cancel, null)
            .setNeutralButton(R.string.refer_to_usage, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setData(Uri
                            .parse("https://github.com/jeffreystoke/openct-mvp#import-from-xlsx-excel-2007"));
                    startActivity(intent);
                }
            }).create();

    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
            positiveButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                        int hasPermission = ContextCompat.checkSelfPermission(getActivity(),
                                Manifest.permission.WRITE_EXTERNAL_STORAGE);
                        if (hasPermission != PackageManager.PERMISSION_GRANTED) {
                            requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                                    REQUEST_EXTERNAL_FILE_WRITE);
                        } else {
                            showFilerChooser();
                        }
                    } else {
                        showFilerChooser();
                    }
                }
            });
        }
    });
    return dialog;
}

From source file:com.scm.reader.resultPage.webview.ShortcutWebViewClient.java

public void overrideEmail(Uri uri) {
    Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
    sendIntent.setData(uri);
    context.startActivity(sendIntent);//from   w  ww  . ja v a 2 s  . c o m
}

From source file:com.scm.reader.resultPage.webview.ShortcutWebViewClient.java

private void overrideSMS(String queryParam) {
    String body = queryParam;/*from  w w w  .jav  a  2  s  . c o m*/
    if (queryParam.split("=").length > 1) {
        body = body.split("=")[1];
    }

    //        Intent it = new Intent(Intent.ACTION_VIEW);
    //        it.putExtra("sms_body", body);
    //        it.setType("vnd.android-dir/mms-sms");
    //        context.startActivity(it);

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("sms:"));
    intent.putExtra("sms_body", body);

    context.startActivity(intent);

}

From source file:com.duguang.baseanimation.ui.listivew.listviews.ListViewsMainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_main_github:
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("http://nhaarman.github.io/ListViewAnimations?ref=app"));
        startActivity(intent);//from   w  ww  .j  a v a  2 s  . c om
        return true;
    case R.id.menu_main_beer:
        buy("beer");
        return true;
    case R.id.menu_main_beer2:
        buy("beer2");
        return true;
    case R.id.menu_main_beer3:
        buy("beer3");
        return true;
    case R.id.menu_main_beer4:
        buy("beer4");
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.gmail.project16543.com.phonegap.plugins.childBrowser.ChildBrowser.java

/**
 * Display a new browser with the specified URL.
 * /* w  w w  .ja  v  a 2  s .c  o m*/
 * NOTE: If usePhoneGap is set, only trusted PhoneGap URLs should be loaded,
 * since any PhoneGap API can be called by the loaded HTML page.
 * 
 * @param url
 *            The url to load.
 * @param usePhoneGap
 *            Load url in PhoneGap webview.
 * @return "" if ok, or error message.
 */
public String showWebPage(String url, boolean usePhoneGap) {
    try {
        Intent intent = null;
        if (usePhoneGap) {
            intent = new Intent().setClass(this.ctx, com.phonegap.DroidGap.class);
            intent.setData(Uri.parse(url));
            intent.putExtra("url", url);
            intent.putExtra("loadUrlTimeoutValue", 60000);

            intent.putExtra("loadingDialog", "Wait,Loading web page...");
            intent.putExtra("hideLoadingDialogOnPageLoad", true);
        } else {
            intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
        }
        this.ctx.startActivity(intent);
        return "";
    } catch (android.content.ActivityNotFoundException e) {
        System.out.println("ChildBrowser: Error loading url " + url + ":" + e.toString());
        return e.toString();
    }
}

From source file:com.haarman.listviewanimations.MainActivity.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_main_github:
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(URL_GITHUB_IO));
        startActivity(intent);//  w  w  w . ja  v a  2 s  . c o m
        return true;
    case R.id.menu_main_beer:
        buy("beer");
        return true;
    case R.id.menu_main_beer2:
        buy("beer2");
        return true;
    case R.id.menu_main_beer3:
        buy("beer3");
        return true;
    case R.id.menu_main_beer4:
        buy("beer4");
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:de.petendi.ethereum.android.EthereumAndroid.java

public void submitTransaction(Activity parentActivity, int requestCode, String transactionString) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setPackage(EthereumAndroidFactory.PACKAGENAME);
    intent.setData(Uri.parse("eth:" + transactionString));
    parentActivity.startActivityForResult(intent, requestCode);
}

From source file:de.petendi.ethereum.android.EthereumAndroid.java

public void requestSignature(Activity parentActivity, int requestCode, String hexEncodedMessage) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setPackage(EthereumAndroidFactory.PACKAGENAME);
    intent.setData(Uri.parse("eth:sign/" + hexEncodedMessage));
    parentActivity.startActivityForResult(intent, requestCode);
}

From source file:org.geometerplus.android.fbreader.network.ActivityNetworkContext.java

@Override
protected boolean authenticateWeb(URI uri, Map<String, String> params) {
    System.err.println("+++ WEB AUTH +++");
    final String authUrl = url(uri, params, "auth-url-web");
    final String completeUrl = url(uri, params, "complete-url-web");
    if (authUrl == null || completeUrl == null) {
        return false;
    }/*from  w  w  w . ja  va  2  s  .c  om*/

    final Intent intent = new Intent(myActivity, WebAuthorisationScreen.class);
    intent.setData(Uri.parse(authUrl));
    intent.putExtra(NetworkLibraryActivity.COMPLETE_URL_KEY, completeUrl);
    startActivityAndWait(intent, NetworkLibraryActivity.REQUEST_WEB_AUTHORISATION_SCREEN);
    System.err.println("--- WEB AUTH ---");
    return true;
}

From source file:luan.com.flippit.GcmIntentService.java

private void extraDialog(String msg, String extraFilename, String extraType) {
    Log.i(MyActivity.TAG, getClass().getName() + ": " + "Extra notification.");

    String url = msg;//from   w ww . j a v  a  2s  .c  o  m
    Intent intentWeb = new Intent(Intent.ACTION_VIEW);
    intentWeb.setData(Uri.parse(url));
    PendingIntent pendingWeb = PendingIntent.getActivity(mContext, 0, intentWeb,
            PendingIntent.FLAG_UPDATE_CURRENT);

    Intent intentCopy = new Intent(mContext, CopyService.class);
    intentCopy.putExtra("msg", msg);
    PendingIntent pendingCopy = PendingIntent.getService(mContext, 0, intentCopy,
            PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder mBuilder = GeneralUtilities.createNotificationBuilder(mContext);
    mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setTicker("Rich message")
            .addAction(R.drawable.send_white, "Open", pendingWeb)
            .addAction(R.drawable.copy_white, "Copy", pendingCopy).setContentText("Rich message");
    mNotificationManager.cancel(1);
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    UpdateHistory updateHistory = new UpdateHistory();
    updateHistory.updateHistory(mContext);
}