List of usage examples for android.content Intent ACTION_VIEW
String ACTION_VIEW
To view the source code for android.content Intent ACTION_VIEW.
Click Source Link
From source file:edu.cwru.apo.Directory.java
public void onClick(View v) { switch (v.getId()) { case R.id.btnCall: Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + lastPhone)); startActivity(intent);/* w ww. j a v a2 s . co m*/ break; case R.id.btnText: startActivity(new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", lastPhone, null))); break; default: String text = ((TextView) v).getText().toString(); int start = text.lastIndexOf('['); int end = text.lastIndexOf(']'); String caseID = text.substring(start + 1, end); Cursor results = database.query("phoneDB", new String[] { "first", "last", "_id", "phone" }, "_id = ?", new String[] { caseID }, null, null, null); if (results.getCount() != 1) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Error Loading Phone Number").setCancelable(false).setNeutralButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } else { results.moveToFirst(); phoneDialog = new Dialog(this); phoneDialog.setContentView(R.layout.phone_dialog); phoneDialog.setTitle(results.getString(0) + " " + results.getString(1)); TextView phoneText = (TextView) phoneDialog.findViewById((R.id.phoneText)); String phoneNumber = removeNonDigits(results.getString(3)); if (phoneNumber == null || phoneNumber.trim().equals("") || phoneNumber.trim().equals("null")) { ((Button) phoneDialog.findViewById(R.id.btnCall)).setEnabled(false); ((Button) phoneDialog.findViewById(R.id.btnText)).setEnabled(false); phoneNumber = "not available"; } else { ((Button) phoneDialog.findViewById(R.id.btnCall)).setEnabled(true); ((Button) phoneDialog.findViewById(R.id.btnText)).setEnabled(true); ((Button) phoneDialog.findViewById(R.id.btnCall)).setOnClickListener(this); ((Button) phoneDialog.findViewById(R.id.btnText)).setOnClickListener(this); } lastPhone = phoneNumber; phoneText.setText("Phone Number: " + lastPhone); phoneDialog.show(); } break; } }
From source file:me.xingrz.finder.EntriesActivity.java
protected Intent intentToView(Uri uri, String mime) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, mime);// w w w . j ava2s. c o m intent.addCategory(Intent.CATEGORY_DEFAULT); for (ResolveInfo resolved : getPackageManager().queryIntentActivities(intent, 0)) { if (BuildConfig.APPLICATION_ID.equals(resolved.activityInfo.packageName)) { intent.setClassName(this, resolved.activityInfo.name); intent.putExtra(EXTRA_ALLOW_BACK, true); } } return intent; }
From source file:com.csipsimple.wizards.impl.OneWorld.java
private void updateAccountInfos(final SipProfile acc) { if (acc != null && acc.id != SipProfile.INVALID_ID) { setFirstViewVisibility(false);/*from ww w. j a va 2 s. co m*/ customWizard.setVisibility(View.VISIBLE); customWizard.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String url = "http://www.1worldsip.com"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); parent.startActivity(i); } }); accountBalanceHelper.launchRequest(acc); } else { if (firstView == null) { firstView = new AccountCreationFirstView(parent); ViewGroup globalContainer = (ViewGroup) settingsContainer.getParent(); firstView.setOnAccountCreationFirstViewListener(this); globalContainer.addView(firstView); } setFirstViewVisibility(true); } }
From source file:fr.bde_eseo.eseomega.lydia.LydiaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Set view / call parent super.onCreate(savedInstanceState); setContentView(R.layout.activity_lydia); context = this; // Init intent flag INTENT_REQUEST intent_request = INTENT_REQUEST.ERROR; // Get intent parameters if (savedInstanceState == null) { Intent intent = getIntent();/*from w w w . ja va 2 s.c o m*/ Bundle extras = intent.getExtras(); String action = intent.getAction(); if (action != null) { // Check if intent's action is correct (obviously yes, but prevents Manifest modifications) if (action.equals(Intent.ACTION_VIEW)) { // Intent depuis Lydia intent_request = INTENT_REQUEST.FROM_LYDIA; // Get all parameters Uri qUri = intent.getData(); // Order ID String sOrderID = qUri.getQueryParameter("id"); if (sOrderID != null) { orderID = Integer.parseInt(sOrderID); } orderType = qUri.getQueryParameter("cat"); } } else if (extras != null) { // Intent interne intent_request = INTENT_REQUEST.FROM_APP; orderID = extras.getInt(Constants.KEY_LYDIA_ORDER_ID); orderType = extras.getString(Constants.KEY_LYDIA_ORDER_TYPE); // Demande de check ? donc ask dj effectu if (extras.getBoolean(Constants.KEY_LYDIA_ORDER_ASKED)) { intent_request = INTENT_REQUEST.FROM_LYDIA; } } } // No intent received if (intent_request == INTENT_REQUEST.ERROR || orderID == -1) { Toast.makeText(context, "Erreur de l'application (c'est pas normal)", Toast.LENGTH_SHORT).show(); close(); } // Get objects userProfile = new UserProfile(); userProfile.readProfilePromPrefs(context); prefsUser = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); // Init dialog dialogInit(); // Get intent type if (intent_request == INTENT_REQUEST.FROM_APP) { /** * FROM_APP : On doit demander le numro de tlphone du client, puis lorsqu'il clique sur "Payer", effectuer une demande de paiement auprs de Lydia. * Il faut ensuite lancer l'Intent vers Lydia avec le bon numro de requte. * * A afficher : * - InputText tlphone * - Checkbox mmorisation numro * - Texte "lgal" sur le numro de tlphone * - Boutons Annuler / Valider AsyncTask ask.php */ dialogFromApp(); } else { /** * FROM_LYDIA : L'activit vient d'tre ouverte aprs que le client ait cliqu sur "Accepter" depuis l'app Lydia. * Dans 100% des cas, le retour notre activit se fait si il a eu un paiement valid. * Cependant, on vrifiera le statut de la commande auprs de notre serveur malgr tout. * * A afficher : * - Texte "tat de votre commande" titre dialogue * - Texte status : actualis toutes les 3 secondes asyncTask * - Bouton Fermer si status diffrent de "en cours" */ dialogFromLydia(); } }
From source file:com.amo.meer.APPVersion.java
private void update() { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory(), UPDATE_SAVENAME)), "application/vnd.android.package-archive"); context.startActivity(intent);/* ww w. ja v a 2 s . co m*/ }
From source file:com.lvlstudios.android.gtmessage.C2DMReceiver.java
@Override public void onMessage(Context context, Intent intent) { Bundle extras = intent.getExtras();/*from w w w . j a va2 s .co m*/ if (extras != null) { String url = (String) extras.get("url"); String title = (String) extras.get("title"); String sel = (String) extras.get("sel"); String debug = (String) extras.get("debug"); Log.d(TAG, String.format("C2DMReceiver.onMessage: url='%s', title='%s', sel='%s'", url, title, sel)); if (debug != null) { // server-controlled debug - the server wants to know we received the message, and when. // This is not user-controllable, // we don't want extra traffic on the server or phone. Server may // turn this on for a small percentage of requests or for users // who report issues. DefaultHttpClient client = new DefaultHttpClient(); HttpGet get = new HttpGet(AppEngineClient.BASE_URL + "/debug?id=" + extras.get("collapse_key")); // No auth - the purpose is only to generate a log/confirm delivery // (to avoid overhead of getting the token) try { client.execute(get); } catch (ClientProtocolException e) { // ignore } catch (IOException e) { // ignore } } if (title != null && url != null && url.startsWith("http")) { SharedPreferences settings = Prefs.get(context); Intent launchIntent = LauncherUtils.getLaunchIntent(context, title, url, sel); // Notify and optionally start activity if (settings.getBoolean("launchBrowserOrMaps", true) && launchIntent != null) { try { context.startActivity(launchIntent); LauncherUtils.playNotificationSound(context); } catch (ActivityNotFoundException e) { return; } } else { if (sel != null && sel.length() > 0) { // have selection LauncherUtils.generateNotification(context, sel, context.getString(R.string.copied_desktop_clipboard), launchIntent); } else { LauncherUtils.generateNotification(context, url, title, launchIntent); } } // Record history (for link/maps only) if (launchIntent != null && launchIntent.getAction().equals(Intent.ACTION_VIEW)) { HistoryDatabase.get(context).insertHistory(title, url); } } } }
From source file:com.robertszkutak.androidexamples.tumblrexample.TumblrExampleActivity.java
@Override public void onResume() { super.onResume(); if (auth == false) { if (browser == true) browser2 = true;//w w w .j a va 2s . co m if (browser == false) { browser = true; newIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(authURL)); startActivity(newIntent); } if (browser2 == true) { Uri uri = getIntent().getData(); uripath = uri.toString(); if (uri != null && uripath.startsWith(OAUTH_CALLBACK_URL)) { String verifier = uri.getQueryParameter(OAuth.OAUTH_VERIFIER); try { provider.retrieveAccessToken(consumer, verifier); token = consumer.getToken(); secret = consumer.getTokenSecret(); final Editor editor = pref.edit(); editor.putString("TUMBLR_OAUTH_TOKEN", token); editor.putString("TUMBLR_OAUTH_TOKEN_SECRET", secret); editor.commit(); auth = true; loggedin = true; } catch (OAuthMessageSignerException e) { e.printStackTrace(); } catch (OAuthNotAuthorizedException e) { e.printStackTrace(); } catch (OAuthExpectationFailedException e) { e.printStackTrace(); } catch (OAuthCommunicationException e) { e.printStackTrace(); } } } } else { setContentView(R.layout.main); blogname = (EditText) findViewById(R.id.blogname); posttitle = (EditText) findViewById(R.id.posttitle); poststring = (EditText) findViewById(R.id.post); debugStatus = (TextView) findViewById(R.id.debug_status); post = (Button) findViewById(R.id.btn_post); loginorout = (Button) findViewById(R.id.loginorout); blogname.setText(pref.getString("TUMBLR_BLOG_NAME", "")); debug = "Access Token: " + token + "\n\nAccess Token Secret: " + secret; debugStatus.setText(debug); post.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isAuthenticated()) { saveBlogName(); sendPost(); } else { Toast toast = Toast.makeText(getApplicationContext(), "You are not logged into Tumblr", Toast.LENGTH_SHORT); toast.show(); } } }); loginorout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { LogInOrOut(); } }); updateLoginStatus(); } if (auth == false && browser2 == true) finish(); }
From source file:com.kakao.kakaolink.KakaoLink.java
/** * ? ?? ./*from w w w . j a v a 2 s . co m*/ * @param builder KakaoTalkLinkMessageBuilder * @param context ? context * @throws KakaoParameterException ? ? ? ? */ public void sendMessage(final KakaoTalkLinkMessageBuilder builder, final Context context) throws KakaoParameterException { final Intent intent = TalkProtocol.createKakakoTalkLinkIntent(context, builder.build()); if (intent == null) { //alert install dialog new AlertDialog.Builder(context).setIcon(android.R.drawable.ic_dialog_alert) .setMessage(context.getString(R.string.com_kakao_alert_install_kakaotalk)) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent marketIntent; try { marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(KakaoTalkLinkProtocol.TALK_MARKET_URL_PREFIX + makeReferrer())); marketIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(marketIntent); } catch (ActivityNotFoundException e) { marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(KakaoTalkLinkProtocol.TALK_MARKET_URL_PREFIX_2 + makeReferrer())); marketIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(marketIntent); } } }).create().show(); } else { context.startActivity(intent); } }
From source file:com.appnexus.opensdk.mediatednativead.InMobiNativeAdResponse.java
boolean setResources(final InMobiNative imNative) { this.imNative = imNative; try {/* ww w .j a v a 2s. co m*/ nativeElements.put(InMobiSettings.NATIVE_ELEMENT_OBJECT, imNative); JSONObject response = new JSONObject((String) imNative.getAdContent()); title = JsonUtil.getJSONString(response, InMobiSettings.KEY_TITLE); callToAction = JsonUtil.getJSONString(response, InMobiSettings.KEY_CALL_TO_ACTION); description = JsonUtil.getJSONString(response, InMobiSettings.KEY_DESCRIPTION); JSONObject iconObject = JsonUtil.getJSONObject(response, InMobiSettings.KEY_ICON); iconUrl = JsonUtil.getJSONString(iconObject, InMobiSettings.KEY_URL); JSONObject imageObject = JsonUtil.getJSONObject(response, InMobiSettings.KEY_IMAGE); imageUrl = JsonUtil.getJSONString(imageObject, InMobiSettings.KEY_URL); if (JsonUtil.getJSONDouble(response, InMobiSettings.KEY_RATING) >= 0) { rating = new Rating(JsonUtil.getJSONDouble(response, InMobiSettings.KEY_RATING), 5); } landingUrl = JsonUtil.getJSONString(response, InMobiSettings.KEY_LANDING_URL); clickListener = new View.OnClickListener() { @Override public void onClick(View v) { imNative.reportAdClick(null); // no additional params passed in for click tracking onAdClicked(); if (v != null && landingUrl != null && !landingUrl.isEmpty()) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(landingUrl)); browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); onAdWillLeaveApplication(); v.getContext().startActivity(browserIntent); } } }; return true; } catch (Exception e) { // Catches JSONException for parsing, // ClassCastException for String casting, // NPE for null imNative } return false; }
From source file:com.codebutler.farebot.activities.AddKeyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_key); getWindow().setLayout(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT); findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { @Override/*from w w w. j a v a2 s .c om*/ public void onClick(View view) { setResult(RESULT_CANCELED); finish(); } }); findViewById(R.id.add).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final String keyType = ((RadioButton) findViewById(R.id.is_key_a)).isChecked() ? ClassicSectorKey.TYPE_KEYA : ClassicSectorKey.TYPE_KEYB; new BetterAsyncTask<Void>(AddKeyActivity.this, true, false) { @Override protected Void doInBackground() throws Exception { ClassicCardKeys keys = ClassicCardKeys.fromDump(keyType, mKeyData); ContentValues values = new ContentValues(); values.put(KeysTableColumns.CARD_ID, mTagId); values.put(KeysTableColumns.CARD_TYPE, mCardType); values.put(KeysTableColumns.KEY_DATA, keys.toJSON().toString()); getContentResolver().insert(CardKeyProvider.CONTENT_URI, values); return null; } @Override protected void onResult(Void unused) { Intent intent = new Intent(AddKeyActivity.this, KeysActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } }.execute(); } }); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); Utils.checkNfcEnabled(this, mNfcAdapter); Intent intent = getIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); mPendingIntent = PendingIntent.getActivity(this, 0, intent, 0); if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_VIEW) && getIntent().getData() != null) { try { InputStream stream = getContentResolver().openInputStream(getIntent().getData()); mKeyData = IOUtils.toByteArray(stream); } catch (IOException e) { Utils.showErrorAndFinish(this, e); } } else { finish(); } }