List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.PictureObj.java
@Override public void activate(Context context, SignedObj obj) { // TODO: set data uri for obj Intent intent = new Intent(context, ImageGalleryActivity.class); intent.setData(Feed.uriForName(obj.getFeedName())); intent.putExtra("objHash", obj.getHash()); if (!(context instanceof Activity)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); }// w w w .j a v a 2 s . c o m context.startActivity(intent); }
From source file:android.security.cts.BrowserTest.java
/** * Create intents for all activities that can display the given URI. *//*w ww . j a va 2s. c o m*/ private List<Intent> createAllIntents(Uri uri) { Intent implicit = new Intent(Intent.ACTION_VIEW); implicit.setData(uri); /* convert our implicit Intent into multiple explicit Intents */ List<Intent> retval = new ArrayList<Intent>(); PackageManager pm = mContext.getPackageManager(); List<ResolveInfo> list = pm.queryIntentActivities(implicit, PackageManager.GET_META_DATA); for (ResolveInfo i : list) { Intent explicit = new Intent(Intent.ACTION_VIEW); explicit.setClassName(i.activityInfo.packageName, i.activityInfo.name); explicit.setData(uri); explicit.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); retval.add(explicit); } return retval; }
From source file:com.sonetel.plugins.sonetelcallthru.CallThru.java
@Override public void onReceive(final Context context, Intent intent) { if (SipManager.ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) { // Retrieve and cache infos from the phone app if (!sPhoneAppInfoLoaded) { Resources r = context.getResources(); BitmapDrawable drawable = (BitmapDrawable) r.getDrawable(R.drawable.ic_wizard_sonetel); sPhoneAppBmp = drawable.getBitmap(); sPhoneAppInfoLoaded = true;/*ww w. jav a 2s . com*/ } Bundle results = getResultExtras(true); //if(pendingIntent != null) { // results.putParcelable(CallHandlerPlugin.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent); //} results.putString(Intent.EXTRA_TITLE, "Call thru");// context.getResources().getString(R.string.use_pstn)); if (sPhoneAppBmp != null) { results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, sPhoneAppBmp); } if (intent.getStringExtra(Intent.EXTRA_TEXT) == null) return; //final PendingIntent pendingIntent = null; final String callthrunum = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); final String dialledNum = intent.getStringExtra(Intent.EXTRA_TEXT); // We must handle that clean way cause when call just to // get the row in account list expect this to reply correctly if (callthrunum != null && PhoneCapabilityTester.isPhone(context)) { if (!callthrunum.equalsIgnoreCase("")) { DBAdapter dbAdapt = new DBAdapter(context); // Build pending intent SipAccount = dbAdapt.getAccount(1); if (SipAccount != null) { Intent i = new Intent(Intent.ACTION_CALL); i.setData(Uri.fromParts("tel", callthrunum, null)); final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); NetWorkThread = new Thread() { public void run() { SendMsgToNetWork(dialledNum, context, pendingIntent); }; }; NetWorkThread.start(); } if (!dialledNum.equalsIgnoreCase("")) { SipCallSessionImpl callInfo = new SipCallSessionImpl(); callInfo.setRemoteContact(dialledNum); callInfo.setIncoming(false); callInfo.callStart = System.currentTimeMillis(); callInfo.setAccId(3); //callInfo.setLastStatusCode(pjsua.PJ_SUCCESS); ContentValues cv = CallLogHelper.logValuesForCall(context, callInfo, callInfo.callStart); context.getContentResolver().insert(SipManager.CALLLOG_URI, cv); } } else { Location_Finder LocFinder = new Location_Finder(context); if (LocFinder.getContryName().startsWith("your")) Toast.makeText(context, "Country of your current location unknown. Call thru not available.", Toast.LENGTH_LONG).show(); else Toast.makeText(context, "No Call thru access number available in " + LocFinder.getContryName(), Toast.LENGTH_LONG).show(); //Toast.makeText(context, "No Call thru access number available in ", Toast.LENGTH_LONG).show(); } } // This will exclude next time tel:xxx is raised from csipsimple treatment which is wanted results.putString(Intent.EXTRA_PHONE_NUMBER, callthrunum); } }
From source file:com.geekytheory.miguelcatalandev.developerdays.Main_Fragment_Social.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { final Tweet tweet = tweets.get(position - 1); String url = "https://twitter.com/" + tweet.getUserNick() + "/status/" + tweet.getTweetUrl(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent);// w w w. j ava2 s. c o m }
From source file:org.geometerplus.android.fbreader.network.BearerAuthenticator.java
private 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 ww w . j a va 2 s . c o m*/ 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:edu.cwru.apo.Directory.java
public void onClick(View v) { switch (v.getId()) { case R.id.btnCall: Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + lastPhone)); startActivity(intent);/* w w w . j ava 2 s. com*/ break; case R.id.btnText: startActivity(new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", lastPhone, null))); break; default: String text = ((TextView) v).getText().toString(); int start = text.lastIndexOf('['); int end = text.lastIndexOf(']'); String caseID = text.substring(start + 1, end); Cursor results = database.query("phoneDB", new String[] { "first", "last", "_id", "phone" }, "_id = ?", new String[] { caseID }, null, null, null); if (results.getCount() != 1) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Error Loading Phone Number").setCancelable(false).setNeutralButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } else { results.moveToFirst(); phoneDialog = new Dialog(this); phoneDialog.setContentView(R.layout.phone_dialog); phoneDialog.setTitle(results.getString(0) + " " + results.getString(1)); TextView phoneText = (TextView) phoneDialog.findViewById((R.id.phoneText)); String phoneNumber = removeNonDigits(results.getString(3)); if (phoneNumber == null || phoneNumber.trim().equals("") || phoneNumber.trim().equals("null")) { ((Button) phoneDialog.findViewById(R.id.btnCall)).setEnabled(false); ((Button) phoneDialog.findViewById(R.id.btnText)).setEnabled(false); phoneNumber = "not available"; } else { ((Button) phoneDialog.findViewById(R.id.btnCall)).setEnabled(true); ((Button) phoneDialog.findViewById(R.id.btnText)).setEnabled(true); ((Button) phoneDialog.findViewById(R.id.btnCall)).setOnClickListener(this); ((Button) phoneDialog.findViewById(R.id.btnText)).setOnClickListener(this); } lastPhone = phoneNumber; phoneText.setText("Phone Number: " + lastPhone); phoneDialog.show(); } break; } }
From source file:me.xingrz.finder.ZipFinderActivity.java
@Override protected RecyclerView.Adapter getAdapter() { List<FileHeader> headers; try {// ww w .j a v a2 s. co m //noinspection unchecked headers = zipFile.getFileHeaders(); } catch (ZipException e) { return null; } return new ZipAdapter(this, headers, getIntent().getStringExtra(EXTRA_PREFIX)) { @Override protected void openFolder(final AbstractFile folder) { handler.postDelayed(new Runnable() { @Override public void run() { Intent intent = new Intent(); intent.setData(getIntent().getData()); intent.putExtra(EXTRA_PREFIX, folder.path); startFinder(intent, ZipFinderActivity.class); } }, START_ACTIVITY_DELAY); } @Override protected void openFile(AbstractFile file) { if (file.isDirectory || file.header == null) { Log.e(TAG, "not a valid file to extract"); return; } extracting = file.header; openFileInZip(); } }; }
From source file:com.example.android.notepad.NotesList.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT); // If no data was given in the intent (because we were started // as a MAIN activity), then use our default content provider. Intent intent = getIntent(); if (intent.getData() == null) { intent.setData(Notes.CONTENT_URI); }/*from www.ja v a 2s . c o m*/ // Inform the list we provide context menus for items getListView().setOnCreateContextMenuListener(this); // Perform a managed query. The Activity will handle closing and requerying the cursor // when needed. Cursor cursor = managedQuery(getIntent().getData(), PROJECTION, null, null, Notes.DEFAULT_SORT_ORDER); // Used to map notes entries from the database to views SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.noteslist_item, cursor, new String[] { Notes.TITLE }, new int[] { android.R.id.text1 }); setListAdapter(adapter); }
From source file:com.jdom.get.stuff.done.android.AndroidApplicationContextFactory.java
public void displayProVersionPromo(String proAppName, String proVersionLink) { final String text = "For the cost of a soda, $0.99, you can enable the following features:\n" + "- No advertisements\n" + "- Sync frequency/action configuration\n" + "- Configure the fields displayed in the add/edit task page.\n\n" + "Click the OK button to load the pro version in the market viewer, or Cancel to stay with the free version."; AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle("Upgrade"); builder.setMessage(text);//from w w w. ja va 2 s . co m builder.setPositiveButton(OK_BUTTON_TEXT, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(Constants.PRO_VERSION_LINK)); activity.startActivity(intent); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); builder.show(); }
From source file:com.byhook.cordova.chromelauncher.ChromeLauncher.java
/** * Executes the request and returns PluginResult. * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback context used when calling back into JavaScript. * @return A PluginResult object with a status and message. *///from w ww.ja v a2 s. c o m public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { PluginResult.Status status = PluginResult.Status.OK; String result = ""; if (action.equals("open")) { String url = args.getString(0); Intent i = new Intent("android.intent.action.MAIN"); i.setComponent(ComponentName.unflattenFromString("com.android.chrome/com.android.chrome.Main")); i.addCategory("android.intent.category.LAUNCHER"); i.setData(Uri.parse(url)); ((Activity) cordova).startActivity(i); } else if (action.equals("checkInstall")) { if (isInstalled("com.android.chrome")) { callbackContext.sendPluginResult(new PluginResult(status, true)); return true; } else { status = PluginResult.Status.ERROR; callbackContext.sendPluginResult(new PluginResult(status, false)); return true; } } else if (action.equals("openStore")) { Uri marketUri = Uri.parse("market://details?id=com.android.chrome"); Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri); ((Activity) cordova).startActivity(marketIntent); } callbackContext.sendPluginResult(new PluginResult(status, result)); return true; }