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.LinkObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { String mimeType = obj.optString(MIME_TYPE); Uri uri = Uri.parse(obj.optString(URI)); if (fileAvailable(mimeType, uri)) { Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW); i.addCategory(Intent.CATEGORY_DEFAULT); i.setType(mimeType);/*from w ww. j a v a 2 s . c o m*/ i.setData(uri); i.putExtra(Intent.EXTRA_TEXT, uri); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); (new PresenceAwareNotify(context)).notify("New content from Musubi", "New Content from Musubi", mimeType + " " + uri, contentIntent); } else { Log.w(TAG, "Received file, failed to handle: " + uri); } }
From source file:DetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); detector = new GestureDetector(this, new GalleryGestureDetector()); listener = new View.OnTouchListener() { @Override/* www . j a v a 2 s.com*/ public boolean onTouch(View v, MotionEvent event) { return detector.onTouchEvent(event); } }; ImageIndex = 0; detailImage = (ImageView) findViewById(R.id.detail_image); detailImage.setOnTouchListener(listener); TextView detailName = (TextView) findViewById(R.id.detail_name); TextView detailDistance = (TextView) findViewById(R.id.detail_distance); TextView detailText = (TextView) findViewById(R.id.detail_text); detailText.setMovementMethod(new ScrollingMovementMethod()); ImageView detailWebLink = (ImageView) findViewById(R.id.detail_web_link); int i = MainActivity.currentItem; Random n = new Random(); int m = n.nextInt((600 - 20) + 1) + 20; setTitle(getString(R.string.app_name) + " - " + MainData.nameArray[i]); detailImage.setImageResource(MainData.detailImageArray[i]); detailName.setText(MainData.nameArray[i]); detailDistance.setText(String.valueOf(m) + " miles"); detailText.setText(MainData.detailTextArray[i]); detailWebLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse(MainData.detailWebLink[MainActivity.currentItem])); startActivity(intent); } }); }
From source file:com.darktalker.cordova.screenshot.Screenshot.java
private void scanPhoto(String imageFileName) { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); File f = new File(imageFileName); Uri contentUri = Uri.fromFile(f);//from w w w .ja v a 2 s .c o m mediaScanIntent.setData(contentUri); this.cordova.getActivity().sendBroadcast(mediaScanIntent); }
From source file:com.krayzk9s.imgurholo.activities.ImgurLinkActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); destroyed = false;/*from www .j a v a 2 s. c om*/ if (getActionBar() != null) getActionBar().setDisplayHomeAsUpEnabled(true); Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); Log.d("New Intent", intent.toString()); if (Intent.ACTION_SEND.equals(action) && type != null) { if (type.startsWith("image/")) { Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show(); Intent serviceIntent = new Intent(this, UploadService.class); if (intent.getExtras() == null) finish(); serviceIntent.setData((Uri) intent.getExtras().get("android.intent.extra.STREAM")); startService(serviceIntent); finish(); } } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { Log.d("sending", "sending multiple"); Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show(); ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); Intent serviceIntent = new Intent(this, UploadService.class); serviceIntent.putParcelableArrayListExtra("images", list); startService(serviceIntent); finish(); } else if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null && intent.getData().toString().startsWith("http://imgur.com/a")) { String uri = intent.getData().toString(); album = uri.split("/")[4]; Log.d("album", album); Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM); fetcher.execute(); } else if (Intent.ACTION_VIEW.equals(action) && intent.getData().toString().startsWith("http://imgur.com/gallery/")) { String uri = intent.getData().toString(); final String album = uri.split("/")[4]; if (album.length() == 5) { Log.d("album", album); Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM); fetcher.execute(); } else if (album.length() == 7) { Log.d("image", album); Fetcher fetcher = new Fetcher(this, "/3/gallery/image/" + album, ApiCall.GET, null, apiCall, IMAGE); fetcher.execute(); } } else if (Intent.ACTION_VIEW.equals(action) && intent.getData().toString().startsWith("http://i.imgur")) { String uri = intent.getData().toString(); final String image = uri.split("/")[3].split("\\.")[0]; Log.d("image", image); Fetcher fetcher = new Fetcher(this, "/3/image/" + image, ApiCall.GET, null, apiCall, IMAGE); fetcher.execute(); } }
From source file:com.doomy.decode.ResultDialogFragment.java
private void createURLIntent(String myURL) { Intent mIntent = new Intent(); mIntent.setAction(Intent.ACTION_VIEW); mIntent.addCategory(Intent.CATEGORY_BROWSABLE); mIntent.setData(Uri.parse(myURL)); startActivity(mIntent);/*from ww w. ja v a2 s.c o m*/ }
From source file:com.example.faisal.sunshine.app.ForecastFragment.java
public void startMap() { preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity()); String location = preferences.getString(getString(R.string.pref_location_key), getString(R.string.pref_location_default)); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("geo:0,0?q=" + location)); startActivity(intent);//from www .java2 s . c o m }
From source file:com.phonegap.bossbolo.plugin.BoloPlugin.java
public void uninstallBPP() { final String packageName = "com.bossbolo.bppapp"; final CordovaPlugin currentPlugin = (CordovaPlugin) this; try {//from w ww .j ava 2 s .c o m ApplicationInfo info = this.cordova.getActivity().getPackageManager().getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES); new AlertDialog.Builder(this.cordova.getActivity()).setTitle("??").setMessage( "?\n ?B++???B++????B++????\n ???") .setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_DELETE); intent.setData(Uri.parse("package:" + packageName)); currentPlugin.cordova.startActivityForResult(currentPlugin, intent, 2298816); } }).show(); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:mobisocial.musubi.objects.PictureObj.java
@Override public void activate(Context context, DbObj obj) { // TODO: set data uri for obj Intent intent = new Intent(context, ImageGalleryActivity.class); intent.setData(obj.getContainingFeed().getUri()); intent.putExtra(ImageGalleryActivity.EXTRA_DEFAULT_OBJECT_ID, obj.getLocalId()); if (!(context instanceof Activity)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); }/*from www .j a v a 2s . com*/ context.startActivity(intent); }
From source file:android.support.v17.leanback.supportleanbackshowcase.app.grid.VideoGridExampleFragment.java
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof VideoCard) { VideoCard itemCard = (VideoCard) item; MediaMetaData metaData = new MediaMetaData(); metaData.setMediaSourcePath(itemCard.getVideoSource()); metaData.setMediaTitle(itemCard.getTitle()); metaData.setMediaArtistName(itemCard.getDescription()); metaData.setMediaAlbumArtUrl(itemCard.getImageUrl()); Intent intent = new Intent(getActivity(), VideoExampleActivity.class); intent.putExtra(VideoExampleActivity.TAG, metaData); intent.setData(Uri.parse(metaData.getMediaSourcePath())); getActivity().startActivity(intent); }//from www.j a v a 2 s . co m }
From source file:fr.bde_eseo.eseomega.hintsntips.TipsFragment.java
@Override public View onCreateView(LayoutInflater rootInfl, ViewGroup container, Bundle savedInstanceState) { // UI//from w w w . j a va2s.co m View rootView = rootInfl.inflate(R.layout.fragment_tips_list, container, false); swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.tips_refresh); swipeRefreshLayout.setColorSchemeColors(R.color.md_blue_800); progCircle = (ProgressBar) rootView.findViewById(R.id.progressList); tv1 = (TextView) rootView.findViewById(R.id.tvListNothing); tv2 = (TextView) rootView.findViewById(R.id.tvListNothing2); img = (ImageView) rootView.findViewById(R.id.imgNoSponsor); 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 + "tips.json"); // Model / objects sponsorItems = new ArrayList<>(); mAdapter = new MyTipsAdapter(getActivity(), sponsorItems); 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.setSponsorItems(sponsorItems); //sponsorItems.add(new SponsorItem("A", "B", "C", "D", "E", null)); mAdapter.notifyDataSetChanged(); // Start download of data AsyncJSON asyncJSON = new AsyncJSON(true); // circle needed for first call asyncJSON.execute(Constants.URL_JSON_SPONSORS); // 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_SPONSORS); } else { swipeRefreshLayout.setRefreshing(false); } } }); // On click listener recList.addOnItemTouchListener( new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) { SponsorItem si = sponsorItems.get(position); if (si.getUrl() != null && si.getUrl().length() > 0) { String url = si.getUrl(); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } } })); return rootView; }