Java Code Examples for android.content.Intent#setData()
The following examples show how to use
android.content.Intent#setData() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: DoingDaily File: SystemHelper.java License: Apache License 2.0 | 6 votes |
/** * 调用系统浏览器 * * @param context * @param url */ public static void SystemBrowser(Context context, String url) { if (context == null) { return; } if (TextUtils.isEmpty(url)) { return; } Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Uri content_url = Uri.parse(url); intent.setData(content_url); if (intent.resolveActivity(context.getPackageManager()) != null) { context.startActivity(Intent.createChooser(intent, context.getString(R.string.tips_select_browser))); } }
Example 2
Source Project: FireFiles File: StandaloneActivity.java License: Apache License 2.0 | 6 votes |
@Override public void onDocumentPicked(DocumentInfo doc) { final FragmentManager fm = getFragmentManager(); if (doc.isDirectory()) { mState.stack.push(doc); mState.stackTouched = true; onCurrentDirectoryChanged(ANIM_DOWN); } else { // Fall back to viewing final Intent view = new Intent(Intent.ACTION_VIEW); view.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); view.setData(doc.derivedUri); try { startActivity(view); } catch (ActivityNotFoundException ex2) { Toast.makeText(this, R.string.toast_no_application, Toast.LENGTH_SHORT).show(); } } }
Example 3
Source Project: narrate-android File: LinksCard.java License: Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { String url = null; switch ((String)v.getTag()) { case "community": url = "https://plus.google.com/communities/106662199081610755624"; break; case "github": url = "https://github.com/timothymiko/narrate-android"; break; case "tasker": url = "https://github.com/timothymiko/narrate-android"; break; } if ( url != null ) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); getContext().startActivity(i); } }
Example 4
Source Project: RedReader File: MainActivity.java License: GNU General Public License v3.0 | 6 votes |
public void onSelected(final PostListingURL url) { if(url == null) { return; } if(twoPane) { postListingController = new PostListingController(url, this); requestRefresh(RefreshableFragment.POSTS, false); } else { final Intent intent = new Intent(this, PostListingActivity.class); intent.setData(url.generateJsonUri()); startActivityForResult(intent, 1); } }
Example 5
Source Project: BatteryFu File: ToggleWidget.java License: GNU General Public License v2.0 | 6 votes |
/** * Initialise the widget views and click handlers * @param context * @param remoteViews */ private void initWidget(Context context, RemoteViews remoteViews) { // put the right icon image on Settings settings = Settings.getSettings(context); if (settings.isEnabled()) { remoteViews.setImageViewResource(R.id.widget_icon, R.drawable.widget_icon_toggle_on); } else { remoteViews.setImageViewResource(R.id.widget_icon, R.drawable.widget_icon_toggle_off); } // separate intent for clicking the icon Intent active = new Intent(context, ToggleWidget.class); active.setAction(ACTION_WIDGET_RECEIVER); active.setData(Uri.parse("click://icon")); PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0); remoteViews.setOnClickPendingIntent(R.id.widget_icon, actionPendingIntent); // vs clicking the text active.setData(Uri.parse("click://text")); actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0); remoteViews.setOnClickPendingIntent(R.id.widget_text, actionPendingIntent); }
Example 6
Source Project: android-atleap File: IntentUtil.java License: Apache License 2.0 | 5 votes |
/** * Create Intent for sending sms. * * @param phoneNumber telephone number * @param body body of sms * @return created intent */ public static Intent sendSms(String phoneNumber, String body) { Intent intent = createIntent(Intent.ACTION_VIEW, null, null); if (!TextUtils.isEmpty(phoneNumber)) { intent.setData(Uri.parse("sms:" + phoneNumber)); } else { intent.setData(Uri.parse("sms:")); //intent.setType("vnd.android-dir/mms-sms"); } intent.putExtra("sms_body", body); return intent; }
Example 7
Source Project: imsdk-android File: TabMainActivity.java License: MIT License | 5 votes |
public void showHongBaoBalance() { if (!TextUtils.isEmpty(QtalkNavicationService.HONGBAO_BALANCE)) { Uri uri = Uri.parse(QtalkNavicationService.HONGBAO_BALANCE); Intent intent = new Intent(this, QunarWebActvity.class); intent.putExtra(Constants.BundleKey.WEB_FROM, Constants.BundleValue.HONGBAO); intent.setData(uri); startActivity(intent); } }
Example 8
Source Project: styT File: ws_Main3Activity.java License: Apache License 2.0 | 5 votes |
public void ajoinQQGroupdata(String key) { Intent intent = new Intent(); intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key)); // 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) try { startActivity(intent); } catch (Exception e) { // 未安装手Q或安装的版本不支持 } }
Example 9
Source Project: Silence File: NotificationState.java License: GNU General Public License v3.0 | 5 votes |
public PendingIntent getQuickReplyIntent(Context context, Recipients recipients) { if (threads.size() != 1) throw new AssertionError("We only support replies to single thread notifications! " + threads.size()); Intent intent = new Intent(context, ConversationPopupActivity.class); intent.putExtra(ConversationActivity.RECIPIENTS_EXTRA, recipients.getIds()); intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, (long)threads.toArray()[0]); intent.setData((Uri.parse("custom://"+System.currentTimeMillis()))); return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); }
Example 10
Source Project: android-dev-challenge File: MainActivity.java License: Apache License 2.0 | 5 votes |
/** * This method is for responding to clicks from our list. * * @param weatherForDay String describing weather details for a particular day */ @Override public void onClick(long date) { // COMPLETED (39) Refactor onClick to build a URI for the clicked date and and pass it with the Intent using setData Intent weatherDetailIntent = new Intent(MainActivity.this, DetailActivity.class); Uri uriForDateClicked = WeatherContract.WeatherEntry.buildWeatherUriWithDate(date); weatherDetailIntent.setData(uriForDateClicked); startActivity(weatherDetailIntent); }
Example 11
Source Project: moVirt File: VmIntentResolver.java License: Apache License 2.0 | 5 votes |
@Override public Intent getDetailIntent(Vm entity, Context context, MovirtAccount account) { if (account == null || entity == null || context == null) { return null; } Intent intent = new Intent(context, VmDetailActivity_.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setData(entity.getUri()); intent.putExtra(Constants.ACCOUNT_KEY, account); return intent; }
Example 12
Source Project: Conversations File: GeoHelper.java License: GNU General Public License v3.0 | 4 votes |
public static ArrayList<Intent> createGeoIntentsFromMessage(Context context, Message message) { final ArrayList<Intent> intents = new ArrayList<>(); final GeoPoint geoPoint; try { geoPoint = parseGeoPoint(message.getBody()); } catch (IllegalArgumentException e) { return intents; } final Conversational conversation = message.getConversation(); final String label = getLabel(context, message); if (isLocationPluginInstalledAndDesired(context)) { Intent locationPluginIntent = new Intent(SHOW_LOCATION_PACKAGE_NAME); locationPluginIntent.putExtra("latitude", geoPoint.getLatitude()); locationPluginIntent.putExtra("longitude", geoPoint.getLongitude()); if (message.getStatus() != Message.STATUS_RECEIVED) { locationPluginIntent.putExtra("jid", conversation.getAccount().getJid().toString()); locationPluginIntent.putExtra("name", conversation.getAccount().getJid().getLocal()); } else { Contact contact = message.getContact(); if (contact != null) { locationPluginIntent.putExtra("name", contact.getDisplayName()); locationPluginIntent.putExtra("jid", contact.getJid().toString()); } else { locationPluginIntent.putExtra("name", UIHelper.getDisplayedMucCounterpart(message.getCounterpart())); } } intents.add(locationPluginIntent); } else { Intent intent = new Intent(context, ShowLocationActivity.class); intent.setAction(SHOW_LOCATION_PACKAGE_NAME); intent.putExtra("latitude", geoPoint.getLatitude()); intent.putExtra("longitude", geoPoint.getLongitude()); intents.add(intent); } intents.add(geoIntent(geoPoint, label)); Intent httpIntent = new Intent(Intent.ACTION_VIEW); httpIntent.setData(Uri.parse("https://maps.google.com/maps?q=loc:"+String.valueOf(geoPoint.getLatitude()) + "," + String.valueOf(geoPoint.getLongitude()) +label)); intents.add(httpIntent); return intents; }
Example 13
Source Project: ground-android File: SettingsFragment.java License: Apache License 2.0 | 4 votes |
private void openUrl(String url) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); }
Example 14
Source Project: fitnotifications File: HomeActivity.java License: Apache License 2.0 | 4 votes |
public static Intent userDonationIntent() { String url = "https://abhijitvalluri.com/android/donate"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); return i; }
Example 15
Source Project: RetroMusicPlayer File: SettingsActivity.java License: GNU General Public License v3.0 | 4 votes |
private void openUrl(String url) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); }
Example 16
Source Project: android File: AboutActivity.java License: MIT License | 4 votes |
/** * @return an {@link Intent} that opens the given {@code url} */ private static Intent getActionIntent(final String url) { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); return intent; }
Example 17
Source Project: Shelter File: SettingsFragment.java License: Do What The F*ck You Want To Public License | 4 votes |
private boolean openSummaryUrl(Preference pref) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(pref.getSummary().toString())); startActivity(intent); return true; }
Example 18
Source Project: materialize File: AboutActivity.java License: GNU General Public License v3.0 | 4 votes |
private void open(String url) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
Example 19
Source Project: Pocket-Plays-for-Twitch File: Service.java License: GNU General Public License v3.0 | 4 votes |
/** * Creates and returns an intent that navigates the user to the Google Play landing page for the app * * @return The intent */ public static Intent getPlayStoreIntent() { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=net.nrask.notifyme")); return intent; }
Example 20
Source Project: NYU-BusTracker-Android File: MainActivity.java License: Apache License 2.0 | 4 votes |
@SuppressWarnings("UnusedParameters") public void callSafeRide(View view) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:12129928267")); startActivity(callIntent); }