List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:jp.co.conit.sss.sn.ex2.fragment.MessagesFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setEmptyText(getString(R.string.no_messages)); // EmptyText????INTERNAL_EMPTY_ID??TextView????? // INTERNAL_EMPTY_ID?ListFragment??EmptyText?ID?????????????ListFragment??????? TextView tx = (TextView) getView().findViewById(INTERNAL_EMPTY_ID); int color = getResources().getColor(R.color.settings_text_color); tx.setTextColor(color);//from w w w. jav a2s. co m getListView().setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { PushMessage pm = (PushMessage) parent.getItemAtPosition(position); String userData = pm.getUserData(); Intent activityIntent = new Intent(); if (StringUtil.isEmpty(userData) || userData.equals("null")) { return; } else { if (userData.startsWith("http")) { activityIntent.setAction(Intent.ACTION_VIEW); activityIntent.setData(Uri.parse(userData)); } else { activityIntent.setClass(mParentActivity, UserDataActivity.class); activityIntent.putExtra("option", userData); } } startActivity(activityIntent); } }); obtainMessagesAsync(); }
From source file:com.afreire.plugins.video.VideoPlayer.java
private void playVideo(String url) throws IOException { if (url.contains("bit.ly/") || url.contains("goo.gl/") || url.contains("tinyurl.com/") || url.contains("youtu.be/")) { //support for google / bitly / tinyurl / youtube shortens URLConnection con = new URL(url).openConnection(); con.connect();//ww w . ja v a 2s . c o m InputStream is = con.getInputStream(); //new redirected url url = con.getURL().toString(); is.close(); } // Create URI Uri uri = Uri.parse(url); Intent intent = null; // Check to see if someone is trying to play a YouTube page. if (url.contains(YOU_TUBE)) { // If we don't do it this way you don't have the option for youtube uri = Uri.parse("vnd.youtube:" + uri.getQueryParameter("v")); if (isYouTubeInstalled()) { intent = new Intent(Intent.ACTION_VIEW, uri); } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=com.google.android.youtube")); } } else if (url.contains(ASSETS)) { // get file path in assets folder String filepath = url.replace(ASSETS, ""); //Remove the path to the file from any location if (filepath.contains("www/file:")) { filepath = filepath.replace("www/file://", ""); } // get actual filename from path as command to write to internal storage doesn't like folders String filename = filepath.substring(filepath.lastIndexOf("/") + 1, filepath.length()); // Don't copy the file if it already exists //File fp = new File(this.cordova.getActivity().getFilesDir() + "/" + filename); //It uses a fixed name to optimize memory space File fp = new File(this.cordova.getActivity().getFilesDir() + "/" + VIDEO_FILE_NAME); //Always copy the file //if (!fp.exists()) { this.copy(filepath, filename); //} // change uri to be to the new file in internal storage uri = Uri.parse("file://" + this.cordova.getActivity().getFilesDir() + "/" + filename); // Display video player intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "video/*"); } else { // Display video player intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "video/*"); } this.cordova.getActivity().startActivity(intent); }
From source file:name.setup.dance.DanceStepApp.java
/** Called when the activity is first created. */ @Override// w ww .j a va2 s . c o m public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "[ACTIVITY] onCreate"); super.onCreate(savedInstanceState); //mStepValue = 0; mPaceValue = 0; setContentView(R.layout.main); mUtils = Utils.getInstance(); String m_szDevIDShort = "35" + //we make this look like a valid IMEI Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + Build.USER.length() % 10; //13 digits mUtils.DeviceName = m_szDevIDShort; Log.v(TAG, "ID: " + m_szDevIDShort); Log.v(TAG, "UTILS: " + mUtils.DeviceName); // user name mTextField = (EditText) findViewById(R.id.name_area); mTextField.setCursorVisible(false); if (!(mUtils.UserName == "My Name")) { mTextField.setText(mUtils.UserName); } mTextField.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // only will trigger it if no physical keyboard is open mgr.showSoftInput(mTextField, InputMethodManager.SHOW_IMPLICIT); mTextField.requestFocus(); mTextField.setCursorVisible(true); mOkayButton.setVisibility(View.VISIBLE); } }); // init okay Button mOkayButton = (Button) findViewById(R.id.okay_button); mOkayButton.setVisibility(View.INVISIBLE); mOkayButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0); mTextField.setCursorVisible(false); mTextField.clearFocus(); mUtils.UserName = mTextField.getText().toString(); // post name via HHTP new Thread(new Runnable() { public void run() { if (mIsMetric) { postHTTP(mUtils.DeviceName, mUtils.UserName, mStepValue, mDistanceValue); } else { postHTTP(mUtils.DeviceName, mUtils.UserName, mStepValue, mDistanceValue * 1.609344f); } } }).start(); mOkayButton.setVisibility(View.INVISIBLE); // Post TOAST MESSAGE Toast.makeText(getApplicationContext(), getText(R.string.name_saved), Toast.LENGTH_SHORT).show(); } }); // init Score Button mScoreButton = (Button) findViewById(R.id.scoreButton); mScoreButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click String url = "http://www.setup.nl/tools/dancestep_app/index.php?id=" + mUtils.DeviceName + "&time=" + System.currentTimeMillis(); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); }
From source file:com.intel.xdk.contacts.Contacts.java
public void editContact(String contactId) { if (busy == true) { String js = "javascript: var e = document.createEvent('Events');e.initEvent('intel.xdk.contacts.busy',true,true);e.success=false;e.message='busy';document.dispatchEvent(e);"; injectJS(js);// ww w . j av a2 s. co m return; } try { //Determine if Contact ID exists Uri res = null; Uri lookupUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, contactId); try { res = ContactsContract.Contacts.lookupContact(activity.getContentResolver(), lookupUri); } catch (Exception e) { e.printStackTrace(); } if (res != null) { busy = true; Intent intent = new Intent(Intent.ACTION_EDIT); contactBeingEdited = contactId; intent.setType(ContactsContract.Contacts.CONTENT_TYPE); intent.setData(res); //launch activity cordova.setActivityResultCallback(this); activity.startActivityForResult(intent, CONTACT_EDIT_RESULT); //activity.setLaunchedChildActivity(true); } else { contactBeingEdited = ""; String errjs1 = String.format( "var e = document.createEvent('Events');e.initEvent('intel.xdk.contacts.edit',true,true);e.success=false;e.error='contact not found';e.contactid='%s';document.dispatchEvent(e);", contactId); injectJS("javascript: " + errjs1); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:mobisocial.bento.anyshare.ui.FeedItemListFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { DbObj obj = mManager.getFeedItemObj(position); if (obj == null) { return;/*from www .j a v a 2 s. c o m*/ } mManager.setContextObj(obj); if (obj.getType().equals(DataManager.TYPE_APP_STATE)) { Intent intent = new Intent(getActivity(), ViewActivity.class); startActivityForResult(intent, HomeActivity.REQUEST_VIEW); } else if (obj.getType().equals(DataManager.TYPE_PICTURE)) { Intent intent = new Intent(getActivity(), ImageViewActivity.class); intent.putExtra("hash", obj.getHash()); startActivityForResult(intent, HomeActivity.REQUEST_VIEW); } else if (obj.getType().equals(DataManager.TYPE_LINK)) { Intent intent = new Intent(Intent.ACTION_VIEW); try { intent.setData(Uri.parse(obj.getJson().getString("uri"))); startActivityForResult(intent, HomeActivity.REQUEST_VIEW); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // super.onListItemClick(l, v, position, id); }
From source file:br.com.hotforms.usewaze.UseWaze.java
private void callWaze(final String url) { final Activity activity = this.cordova.getActivity(); activity.runOnUiThread(new Runnable() { @Override//from w w w .j av a2 s .com public void run() { try { Intent intent = null; intent = new Intent(Intent.ACTION_VIEW); // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent". // Adding the MIME type to http: URLs causes them to not be handled by the downloader. Uri uri = Uri.parse(url); if ("file".equals(uri.getScheme())) { intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri)); } else { intent.setData(uri); } activity.startActivity(intent); } catch (ActivityNotFoundException ex) { String urlMarket = "market://details?id=com.waze"; Intent intent = null; intent = new Intent(Intent.ACTION_VIEW); // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent". // Adding the MIME type to http: URLs causes them to not be handled by the downloader. Uri uri = Uri.parse(urlMarket); if ("file".equals(uri.getScheme())) { intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri)); } else { intent.setData(uri); } activity.startActivity(intent); } } }); }
From source file:com.futureplatforms.kirin.extensions.localnotifications.LocalNotificationsBackend.java
public Intent createIntentForSchedule(String idString) { Intent intent = new Intent(mContext, LocalNotificationAlarmReceiver.class); // Determine if two intents are the same for the purposes of // intent resolution (filtering). // That is, if their action, data, type, class, and categories are the // same./*from w w w . j a v a 2s . c o m*/ // This does not compare any extra data included in the intents. intent.setData(Uri.withAppendedPath(BASE_URI_NOTIFICATION, idString)); intent.setAction(C.ACTION_LOCAL_NOTIFICATION); return intent; }
From source file:com.moust.cordova.videoplayer.VideoPlayer.java
private void playVideo(String url) throws IOException { if (url.contains("bit.ly/") || url.contains("goo.gl/") || url.contains("tinyurl.com/") || url.contains("youtu.be/")) { //support for google / bitly / tinyurl / youtube shortens URLConnection con = new URL(url).openConnection(); con.connect();//from w ww .j ava 2 s.c o m InputStream is = con.getInputStream(); //new redirected url url = con.getURL().toString(); is.close(); } // Create URI Uri uri = Uri.parse(url); Intent intent = null; // Check to see if someone is trying to play a YouTube page. if (url.contains(YOU_TUBE)) { // If we don't do it this way you don't have the option for youtube uri = Uri.parse("vnd.youtube:" + uri.getQueryParameter("v")); if (isYouTubeInstalled()) { intent = new Intent(Intent.ACTION_VIEW, uri); } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=com.google.android.youtube")); } } else if (url.contains(ASSETS)) { // get file path in assets folder String filepath = url.replace(ASSETS, ""); //Remove the path to the file from any location if (filepath.contains("www/file:")) { filepath = filepath.replace("www/file://", ""); } // get actual filename from path as command to write to internal storage doesn't like folders String filename = filepath.substring(filepath.lastIndexOf("/") + 1, filepath.length()); // Don't copy the file if it already exists //File fp = new File(this.cordova.getActivity().getFilesDir() + "/" + filename); //It uses a fixed name to optimize memory space File fp = new File(this.cordova.getActivity().getFilesDir() + "/" + VIDEO_FILE_NAME); //Always copy the file //if (!fp.exists()) { this.copy(filepath, filename); //} // change uri to be to the new file in internal storage uri = Uri.parse("file://" + this.cordova.getActivity().getFilesDir() + "/" + filename); // Display video player intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "video/*"); } else { // Display video player intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "video/*"); } this.cordova.getActivity().startActivity(intent); }
From source file:org.bwgz.quotation.activity.QuotationActivity.java
private void loadQuote(Uri uri) { Log.d(TAG, String.format("loadQuote - uri: %s", uri)); setLoadState(LoadState.LOADING);/*from www . ja v a 2 s . com*/ Intent intent = getIntent(); if (intent != null) { intent.setData(uri); } initLoaders(getSupportLoaderManager(), uri); }
From source file:com.spydiko.rotationmanager.MainActivity.java
public void showPlayStoreDialog(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(this); // Add the buttons builder.setTitle("Spydiko"); builder.setMessage(R.string.landing_msg); builder.setIcon(R.drawable.icon);//from w w w .ja v a 2s . c o m builder.setPositiveButton(R.string.playStore, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User clicked OK button Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://search?q=pub:Spydiko")); startActivity(intent); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Set other dialog properties // Create the AlertDialog AlertDialog dialog = builder.create(); // AppSpecificOrientation.ALREADY_SHOWED = true; // AppSpecificOrientation.RETURN_FROM_ABOUT = false; dialog.show(); }