List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:com.seamusdawkins.autocomplete.MainActivity.java
/** * This method implementing a listener//from w ww. j ava 2s . c om */ public void initListener() { mapFragment.getMapAsync(this); autoCompView.setAdapter(new GooglePlacesAutocompleteAdapter(this, R.layout.list_item_autocomplete)); autoCompView.setOnItemClickListener(this); floatButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url = "https://github.com/cleidimarviana/places-autocomplete-and-gps-coordinates"; Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); } }); }
From source file:com.futureplatforms.kirin.extensions.localnotifications.LocalNotificationsBackend.java
@SuppressWarnings("deprecation") public Notification createNotification(Bundle settings, JSONObject obj) { // notifications[i] = api.normalizeAPI({ // 'string': { // mandatory: ['title', 'body'], // defaults: {'icon':'icon'} // },//from ww w . j a va 2s .c om // // 'number': { // mandatory: ['id', 'timeMillisSince1970'], // // the number of ms after which we start prioritising more recent // things above you. // defaults: {'epsilon': 1000 * 60 * 24 * 365} // }, // // 'boolean': { // defaults: { // 'vibrate': false, // 'sound': false // } // } int icon = settings.getInt("notification_icon", -1); if (icon == -1) { Log.e(C.TAG, "Need a notification_icon resource in the meta-data of LocalNotificationsAlarmReceiver"); return null; } Notification n = new Notification(); n.icon = icon; n.flags = Notification.FLAG_ONLY_ALERT_ONCE | Notification.FLAG_AUTO_CANCEL; long alarmTime = obj.optLong("timeMillisSince1970"); long displayTime = obj.optLong("displayTimestamp", alarmTime); n.when = displayTime; n.tickerText = obj.optString("body"); n.setLatestEventInfo(mContext, obj.optString("title"), obj.optString("body"), null); if (obj.optBoolean("vibrate")) { n.defaults |= Notification.DEFAULT_VIBRATE; } if (obj.optBoolean("sound")) { n.defaults |= Notification.DEFAULT_SOUND; } String uriString = settings.getString("content_uri_prefix"); if (uriString == null) { Log.e(C.TAG, "Need a content_uri_prefix in the meta-data of LocalNotificationsAlarmReceiver"); return null; } if (uriString.contains("%d")) { uriString = String.format(uriString, obj.optInt("id")); } Uri uri = Uri.parse(uriString); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(uri); n.contentIntent = PendingIntent.getActivity(mContext, 23, intent, PendingIntent.FLAG_ONE_SHOT); return n; }
From source file:net.openid.appauth.AuthorizationManagementActivity.java
private void handleAuthorizationComplete() { UriParser responseUri = new UriParser(getIntent().getData()); Intent responseData = extractResponseData(responseUri); if (responseData == null) { Logger.error("Failed to extract OAuth2 response from redirect"); return;/*w w w . ja v a 2 s . co m*/ } responseData.setData(getIntent().getData()); Logger.debug("Authorization complete - invoking completion intent"); try { mCompleteIntent.send(this, 0, responseData); } catch (CanceledException ex) { Logger.error("Failed to send completion intent", ex); } }
From source file:net.openid.appauthdemo.Configuration.java
private boolean isRedirectUriRegistered() { // ensure that the redirect URI declared in the configuration is handled by some activity // in the app, by querying the package manager speculatively Intent redirectIntent = new Intent(); redirectIntent.setPackage(mContext.getPackageName()); redirectIntent.setAction(Intent.ACTION_VIEW); redirectIntent.addCategory(Intent.CATEGORY_BROWSABLE); redirectIntent.setData(mRedirectUri); return !mContext.getPackageManager().queryIntentActivities(redirectIntent, 0).isEmpty(); }
From source file:com.mono.applink.Foursquare.java
/** Called when the activity is first created. */ @Override// www . ja va 2 s . com public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String url = getIntent().getData().toString(); if (url.contains("user"))//user with id { new FoursquareUser().execute(); } else if (url.contains("venue")) { new FoursquareVenue().execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Sorry, but this type of link is not currently supported"); builder.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setData(Uri.parse(url)); startActivity(i); finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:org.youaretheone.website.client.UoneSearchGsonActivity.java
private void checkTab() { if (mMenuPanel != null) { if (mMenuPanel.getVisibility() == View.VISIBLE) { toggleMenu();//from w w w . j av a2 s .c o m } switch (mTabHost.getCurrentTab()) { case TabItem.SEARCH: content.setText(getString(R.string.search)); (new UoneSearchTask()).execute(); break; case TabItem.SHARE: content.setText(getString(R.string.share)); (new UoneSearchTask()).execute(); break; case TabItem.WEBSITE: content.setText(getString(R.string.website)); final Intent visit = new Intent(Intent.ACTION_VIEW); visit.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); visit.setData(android.net.Uri.parse(WEBSITE)); // Use a thread so that the menu is responsive when // clicked new Thread(new Runnable() { public void run() { startActivity(visit); } }).start(); break; case TabItem.SETTINGS: content.setText(getString(R.string.settings)); (new UoneSearchTask()).execute(); break; case TabItem.QUIT: content.setText(getString(R.string.quit)); new Thread(new Runnable() { public void run() { UoneSearchGsonActivity.this.finish(); // The following makes the Android Gods frown // upon me android.os.Process.killProcess(android.os.Process.myPid()); System.exit(0); } }).start(); break; default: break; } // Handle click on currently selected tab - hide menu bar // IMPORTANT: This listener has to appear AFTER the tabs are // added // Unfortunately, This doesn't work when the current tab // contains an activity (except for tab 0) // If you only have method tabs then it works perfect mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleMenu(); } }); // if you want to reset the current tab // mTabHost.setCurrentTab(0); } }
From source file:com.polyvi.xface.view.XWebViewClient.java
/** * ?url?? url ??url//from ww w . j a v a2 s . c o m */ private boolean startSysApplication(String url) { Intent intent = null; if (url.contains("content://media/external")) { intent = new Intent(Intent.ACTION_PICK); } else { intent = new Intent(Intent.ACTION_VIEW); } intent.setData(Uri.parse(url)); try { mSystemContext.getContext().startActivity(intent); } catch (ActivityNotFoundException e) { XLog.e(CLASS_NAME, e.toString()); } return true; }
From source file:com.shopify.sample.activity.CheckoutActivity.java
private void launchBrowser(String url) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.setData(Uri.parse(url)); try {//from w w w .j ava2s .com intent.setPackage("com.android.chrome"); startActivity(intent); } catch (Exception launchChromeException) { try { // Chrome could not be opened, attempt to us other launcher intent.setPackage(null); startActivity(intent); } catch (Exception launchOtherException) { onError(getString(R.string.checkout_error)); } } }
From source file:com.mono.applink.Twitter.java
/** Called when the activity is first created. */ @Override//from w w w . j a va 2s .c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String url = getIntent().getData().toString(); if (url.contains("twitter.com") && !url.contains("status") && !url.contains("direct_messages") && !url.contains("user_spam_reports") && !url.contains("account") && !url.contains("settings"))//Just if it is a link of a user profile { new TwitterUser().execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Sorry, but this type of link is not currently supported"); builder.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setData(Uri.parse(url)); startActivity(i); finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }