List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:com.codeskraps.lolo.misc.Utils.java
public static PendingIntent getOnTouchIntent(Context context) { PendingIntent pendingIntent = null;/*www . j a v a 2 s.co m*/ Intent intent = null; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); int onClick = Integer.parseInt(prefs.getString(Constants.ONCLICK, "0")); switch (onClick) { case 0: intent = new Intent("com.codeskraps.lol.DO_NOTHING"); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 1: intent = new Intent(context, TweetsFeedActivity.class); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 2: intent = new Intent(); intent.setAction(Constants.BROADCAST_RECEIVER); pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 3: intent = new Intent(context, PrefsActivity.class); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 4: intent = new Intent(Intent.ACTION_VIEW); String url = prefs.getString(Constants.EURL, context.getString(R.string.prefsURL_default)); if (!url.startsWith("http://")) url = "http://" + url; intent.setData(Uri.parse(url)); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; } return pendingIntent; }
From source file:com.dnielfe.manager.AppManager.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); int index = info.position; String packagename = mAppList.get(index).packageName; switch (item.getItemId()) { case ID_LAUNCH: Intent i = pm.getLaunchIntentForPackage(packagename); startActivity(i);// www .j av a 2s . c o m break; case ID_MANAGE: startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + packagename))); break; case ID_UNINSTALL: Intent i1 = new Intent(Intent.ACTION_DELETE); i1.setData(Uri.parse("package:" + packagename)); startActivity(i1); get_downloaded_apps(); break; case ID_MARKET: Intent intent1 = new Intent(Intent.ACTION_VIEW); intent1.setData(Uri.parse("market://details?id=" + packagename)); startActivity(intent1); break; case ID_SEND: try { ApplicationInfo info1 = pm.getApplicationInfo(packagename, 0); String source_dir = info1.sourceDir; File file = new File(source_dir); Uri uri11 = Uri.fromFile(file.getAbsoluteFile()); Intent infointent = new Intent(Intent.ACTION_SEND); infointent.setType("application/zip"); infointent.putExtra(Intent.EXTRA_STREAM, uri11); startActivity(Intent.createChooser(infointent, getString(R.string.share))); } catch (Exception e) { Toast.makeText(AppManager.this, "Error", Toast.LENGTH_SHORT).show(); } break; } return false; }
From source file:com.krayzk9s.imgurholo.services.UploadService.java
public void onGetObject(Object o, String tag) { String id = (String) o; if (id.length() == 7) { if (totalUpload != -1) ids.add(id);//from ww w . j ava2s. c o m if (ids.size() == totalUpload) { ids.add(0, ""); //weird hack because imgur eats the first item of the array for some bizarre reason NewAlbumAsync newAlbumAsync = new NewAlbumAsync("", "", apiCall, ids, this); newAlbumAsync.execute(); } } else if (apiCall.settings.getBoolean("AlbumUpload", true)) { NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this); Intent viewImageIntent = new Intent(); viewImageIntent.setAction(Intent.ACTION_VIEW); viewImageIntent.setData(Uri.parse("http://imgur.com/a/" + id)); Intent shareIntent = new Intent(); shareIntent.setType("text/plain"); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.putExtra(Intent.EXTRA_TEXT, "http://imgur.com/a/" + id); PendingIntent viewImagePendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), viewImageIntent, 0); PendingIntent sharePendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), shareIntent, 0); Notification notification = notificationBuilder.setSmallIcon(R.drawable.icon_desaturated) .setContentText("Finished Uploading Album").setContentTitle("imgur Image Uploader") .setContentIntent(viewImagePendingIntent) .addAction(R.drawable.dark_social_share, "Share", sharePendingIntent).build(); Log.d("Built", "Notification built"); notificationManager.cancel(0); notificationManager.notify(1, notification); Log.d("Built", "Notification display"); } else { NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this); Notification notification = notificationBuilder.setSmallIcon(R.drawable.icon_desaturated) .setContentText("Finished Uploading All Images").setContentTitle("imgur Image Uploader") .build(); Log.d("Built", "Notification built"); notificationManager.cancel(0); notificationManager.notify(1, notification); Log.d("Built", "Notification display"); } }
From source file:fr.bde_eseo.eseomega.events.EventsFragment.java
@Override public View onCreateView(LayoutInflater rootInfl, ViewGroup container, Bundle savedInstanceState) { // UI/*from ww w.j av a2 s .co m*/ View rootView = rootInfl.inflate(R.layout.fragment_event_list, container, false); swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.events_refresh); swipeRefreshLayout.setColorSchemeColors(R.color.md_blue_800); progCircle = (ProgressBar) rootView.findViewById(R.id.progressEvent); tv1 = (TextView) rootView.findViewById(R.id.tvListNothing); tv2 = (TextView) rootView.findViewById(R.id.tvListNothing2); img = (ImageView) rootView.findViewById(R.id.imgNoEvent); progCircle.setVisibility(View.GONE); progCircle.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.md_grey_500), PorterDuff.Mode.SRC_IN); tv1.setVisibility(View.GONE); tv2.setVisibility(View.GONE); img.setVisibility(View.GONE); disabler = new RecyclerViewDisabler(); // I/O cache data cachePath = getActivity().getCacheDir() + "/"; cacheFileEseo = new File(cachePath + "events.json"); // Init static model TicketStore.getInstance().reset(); // Model / objects eventItems = TicketStore.getInstance().getEventItems(); mAdapter = new MyEventsAdapter(getActivity(), eventItems); recList = (RecyclerView) rootView.findViewById(R.id.recyList); recList.setAdapter(mAdapter); recList.setHasFixedSize(false); LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); recList.setLayoutManager(llm); mAdapter.setEventItems(eventItems); mAdapter.notifyDataSetChanged(); // Start download of data AsyncJSON asyncJSON = new AsyncJSON(true); // circle needed for first call asyncJSON.execute(Constants.URL_JSON_EVENTS); // On click listener recList.addOnItemTouchListener( new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) { final EventItem ei = eventItems.get(position); if (!ei.isHeader()) { boolean hasUrl = ei.getUrl() != null && ei.getUrl().length() != 0; boolean hasPlace = ei.getLieu() != null && ei.getLieu().length() != 0; boolean isAllDay = false; MaterialDialog.Builder mdb = new MaterialDialog.Builder(getActivity()) .customView(R.layout.dialog_event, false).positiveText("Ajouter au calendrier"); if (hasUrl) mdb.neutralText("Consulter le site"); if (hasPlace) mdb.negativeText("Y aller"); mdb.callback(new MaterialDialog.ButtonCallback() { @Override public void onNegative(MaterialDialog dialog) { // Intent : go to address super.onNegative(dialog); try { Uri gmmIntentUri = Uri.parse("geo:0,0?q=" + Uri.encode(ei.getLieu())); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); startActivity(mapIntent); } catch (ActivityNotFoundException ex) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.apps.maps")); startActivity(intent); } } @Override public void onPositive(MaterialDialog dialog) { // Intent : add to calendar super.onPositive(dialog); startActivity(ei.toCalendarIntent()); } @Override public void onNeutral(MaterialDialog dialog) { // Intent : go to website super.onNeutral(dialog); String url = ei.getUrl(); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); MaterialDialog md = mdb.show(); View mdView = md.getView(); ((TextView) mdView.findViewById(R.id.tvEventName)).setText(ei.getName()); (mdView.findViewById(R.id.rlBackDialogEvent)).setBackgroundColor(ei.getColor()); if (ei.getDetails() != null && ei.getDetails().length() > 0) { ((TextView) mdView.findViewById(R.id.tvEventDetails)).setText(ei.getDetails()); } else { ((TextView) mdView.findViewById(R.id.tvEventDetails)) .setText("Que souhaitez vous faire ?"); } if (ei.getLieu() != null && ei.getLieu().length() > 0) { ((TextView) mdView.findViewById(R.id.tvEventPlace)) .setText("Lieu : " + ei.getLieu()); ((TextView) mdView.findViewById(R.id.tvEventPlace)).setVisibility(View.VISIBLE); } else { ((TextView) mdView.findViewById(R.id.tvEventPlace)).setVisibility(View.GONE); } } } })); // Swipe-to-refresh implementations timestamp = 0; swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { //Toast.makeText(getActivity(), "Refreshing ...", Toast.LENGTH_SHORT).show(); long t = System.currentTimeMillis() / 1000; if (t - timestamp > LATENCY_REFRESH) { // timestamp in seconds) timestamp = t; AsyncJSON asyncJSON = new AsyncJSON(false); // no circle here (already in SwipeLayout) asyncJSON.execute(Constants.URL_JSON_EVENTS); } else { swipeRefreshLayout.setRefreshing(false); } } }); return rootView; }
From source file:com.groupme.sdk.GroupMeConnect.java
/** * Opens the Android Market to download the GroupMe application. * * @since 1// w w w . j a va 2 s . c om */ public void downloadGroupMeApp() { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse("market://details?id=com.groupme.android")); mContext.startActivity(intent); }
From source file:com.example.ridemepassenger.WaitHeComeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SDKInitializer.initialize(getApplicationContext()); setContentView(R.layout.activity_wait_he_come); Bundle extras = getIntent().getExtras(); d_name = extras.getString(DRIVERNAME); d_phone = extras.getString(DRIVERPHONE); d_avatar = extras.getString(DRIVEAVATAR); d_license = extras.getString(DRIVERLICENSE); d_model = extras.getString(DRIVERMODEL); d_stars = extras.getString(DRIVERSTARS); d_dealnum = extras.getString(DRIVERDEALNUM); name_txt = (TextView) findViewById(R.id.wait_he_come_name); license_txt = (TextView) findViewById(R.id.wait_he_come_license); model_txt = (TextView) findViewById(R.id.wait_he_come_model); dealnum_txt = (TextView) findViewById(R.id.wait_he_come_tradenum); avatar = (ImageView) findViewById(R.id.show_order_avatar); dial = (ImageView) findViewById(R.id.wait_he_come_dial); commit_btn = (Button) findViewById(R.id.wait_he_come_bt); name_txt.setText(d_name);//from w w w. java2 s . c om license_txt.setText(d_license); model_txt.setText(d_license); dealnum_txt.setText(d_dealnum); new GetImageCache(avatar, GetImageCache.PIC_NAME).execute(d_avatar); commit_btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub new sendto_sever().execute(); } }); dial.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(); intent.setAction("android.intent.action.CALL"); intent.setData(Uri.parse("tel:" + d_phone));//mobile startActivity(intent); } }); mMapView = (MapView) findViewById(R.id.bmapView); mMapView.showScaleControl(false); mMapView.showZoomControls(false); mBaiduMap = mMapView.getMap(); mBaiduMap.setMapStatus(MapStatusUpdateFactory.zoomTo(19f)); // mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL); mLocationClient = new LocationClient(getApplicationContext()); //LocationClient initLocation(); mLocationClient.registerLocationListener(myListener); // mLocationClient.start(); }
From source file:com.google.android.apps.paco.FeedbackActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); experimentProviderUtil = new ExperimentProviderUtil(this); experiment = getExperimentFromIntent(); if (experiment == null) { displayNoExperimentMessage();/*from w w w . j a v a 2 s . c om*/ } else { setContentView(R.layout.feedback); experimentProviderUtil.loadLastEventForExperiment(experiment); rawDataButton = (Button) findViewById(R.id.rawDataButton); rawDataButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent rawDataIntent = new Intent(FeedbackActivity.this, RawDataActivity.class); rawDataIntent.setData(getIntent().getData()); startActivity(rawDataIntent); } }); webView = (WebView) findViewById(R.id.feedbackText); webView.getSettings().setJavaScriptEnabled(true); final Feedback feedback = experiment.getFeedback().get(0); injectObjectsIntoJavascriptEnvironment(feedback); setWebChromeClientThatHandlesAlertsAsDialogs(); WebViewClient webViewClient = createWebViewClientThatHandlesFileLinksForCharts(feedback); webView.setWebViewClient(webViewClient); if (experiment.getFeedbackType() == FeedbackDAO.FEEDBACK_TYPE_RETROSPECTIVE) { // TODO get rid of this and just use the customFeedback view loadOldDefaultFeedbackIntoWebView(); } else { loadCustomFeedbackIntoWebView(); } if (savedInstanceState != null) { webView.loadUrl((String) savedInstanceState.get("url")); String showDialogString = (String) savedInstanceState.get("showDialog"); if (showDialogString.equals("false")) { showDialog = false; } else { showDialog = true; } } } }
From source file:com.felkertech.n.cumulustv.activities.MainActivity.java
public void moreClick() { String[] actions = new String[] { getString(R.string.settings_browse_plugins), getString(R.string.settings_switch_google_drive), getString(R.string.settings_refresh_cloud_local), getString(R.string.settings_view_licenses), getString(R.string.settings_reset_channel_data), getString(R.string.settings_about)/*, getString(R.string.about_mlc)*/ };//ww w. j a v a 2 s . c o m new MaterialDialog.Builder(this).title(R.string.more_actions).items(actions) .itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) { switch (i) { case 0: ActivityUtils.browsePlugins(MainActivity.this); break; case 1: ActivityUtils.switchGoogleDrive(MainActivity.this, gapi); break; case 2: ActivityUtils.readDriveData(MainActivity.this, gapi); break; case 3: ActivityUtils.oslClick(MainActivity.this); break; case 4: ActivityUtils.deleteChannelData(MainActivity.this, gapi); break; case 5: ActivityUtils.openAbout(MainActivity.this); break; case 6: new MaterialDialog.Builder(MainActivity.this).title(R.string.about_mlc) .content(R.string.about_mlc_summary).positiveText(R.string.about_mlc_issues) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); Intent gi = new Intent(Intent.ACTION_VIEW); gi.setData(Uri.parse( "https://bitbucket.org/fleke" + "r/mlc-music-live-channels")); startActivity(gi); } }).show(); case 13: final OkHttpClient client = new OkHttpClient(); new Thread(new Runnable() { @Override public void run() { Request request = new Request.Builder() .url("http://felkerdigitalmedia.com/sampletv.xml").build(); Response response = null; try { response = client.newCall(request).execute(); // Log.d(TAG, response.body().string().substring(0,36)); String s = response.body().string(); List<com.felkertech.channelsurfer.model.Program> programs = XmlTvParser .parse(response.body().byteStream()).getAllPrograms(); /*Log.d(TAG, programs.toString()); Log.d(TAG, "Parsed "+programs.size()); Log.d(TAG, "Program 1: "+ programs.get(0).getTitle());*/ } catch (IOException e) { e.printStackTrace(); } } }).start(); break; } } }).show(); }
From source file:com.cricketkorner.cricket.VitamioListActivity.java
@Override public void onBackPressed() { AlertDialog.Builder alert = new AlertDialog.Builder(VitamioListActivity.this); alert.setTitle("Please Rate This App."); alert.setMessage("We highly appreciate you to rate us."); alert.setPositiveButton("I will Rate. :-)", new DialogInterface.OnClickListener() { @Override//from www . j av a 2s. c o m public void onClick(DialogInterface dialog, int whichButton) { String url = "https://play.google.com/store/apps/details?id=com.cricketkorner.cricket"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); alert.setNegativeButton("No Thanks :-(", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { finish(); } }); alert.show(); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.StatusObj.java
@Override public void activate(Context context, SignedObj obj) { //linkify should have picked it up already but if we are in TV mode we //still need to activate Intent intent = new Intent(Intent.ACTION_VIEW); String text = obj.getJson().optString(TEXT); //launch the first thing that looks like a link Matcher m = p.matcher(text);//from w w w . j av a 2 s. c o m while (m.find()) { Uri uri = Uri.parse(m.group()); String scheme = uri.getScheme(); if (scheme != null && (scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("https"))) { intent.setData(uri); if (!(context instanceof Activity)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } context.startActivity(intent); return; } } }