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:com.example.muzei.muzeiapod.ApodNasaArtSource.java
@Override protected void onTryUpdate(int reason) throws RetryException { URI topUri;// w w w.ja v a 2 s . co m try { topUri = new URI("http://apod.nasa.gov/"); } catch (URISyntaxException e) { return; } URI mainUri = topUri.resolve("/apod/astropix.html"); String bodyStr = getURLContent(mainUri.toString()); /* TODO code below should go to a separate method/class */ /* start parsing page */ Document doc = Jsoup.parse(bodyStr); Element body = doc.body(); /* get image URI */ Element firstCenterTag = body.child(0); Element imgAnchor = firstCenterTag.getElementsByTag("a").last(); Element img = imgAnchor.getElementsByTag("img").first(); URI bigImageUri = topUri.resolve("/apod/" + img.attr("src")); String uri = bigImageUri.toString(); /* get title */ Element secondCenterTag = body.child(1); Element titleElem = secondCenterTag.child(0); String title = titleElem.text(); /* get byline */ String secondCenterText = secondCenterTag.text(); /* byline: everything after 'title' above */ int idx = secondCenterText.lastIndexOf(title) + title.length(); String byline = secondCenterText.substring(idx).trim(); /* TODO figure out the permanent link */ String link = "http://apod.nasa.gov/apod/astropix.html"; publishArtwork(new Artwork.Builder().title(title).byline(byline).imageUri(Uri.parse(uri)).token(title) .viewIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(link))).build()); scheduleUpdate(System.currentTimeMillis() + ROTATE_TIME_MILLIS); }
From source file:fr.mixit.android.ui.SpeakerDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_speaker_detail); cacheDir = getCacheDir();//from w w w .j a v a 2s . c o m ((TextView) findViewById(R.id.title_text)).setText(getTitle()); mName = (TextView) findViewById(R.id.speaker_name); mCompany = (TextView) findViewById(R.id.speaker_company); mLinkedIn = (ImageButton) findViewById(R.id.speaker_linkedin); mLinkedIn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mLinkedInURL != null && mLinkedInURL.length() > 0) { Uri uri = Uri.parse(mLinkedInURL); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } } }); mTwitter = (ImageButton) findViewById(R.id.speaker_twitter); mTwitter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mTwitterURL != null && mTwitterURL.length() > 0) { Uri uri = Uri.parse(mTwitterURL); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } } }); mBlog = (ImageButton) findViewById(R.id.speaker_blog); mBlog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mBlogURL != null && mBlogURL.length() > 0) { Uri uri = Uri.parse(mBlogURL); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } } }); mBio = (TextView) findViewById(R.id.speaker_bio); mImage = (SpeakerImageView) findViewById(R.id.speaker_image); final Intent intent = getIntent(); mSpeakerUri = intent.getData(); mSpeakerId = getSpeakerId(mSpeakerUri); setupBioTab(); setupPresentationsTab(); mHandler = new NotifyingAsyncQueryHandler(getContentResolver(), this); mHandler.startQuery(mSpeakerUri, SpeakersQuery.PROJECTION); StarredSender.getInstance().startStarredDispatcher(getApplicationContext()); }
From source file:com.android.stockbrowser.search.OpenSearchSearchEngine.java
public void startSearch(Context context, String query, Bundle appData, String extraData) { String uri = mSearchEngineInfo.getSearchUriForQuery(query); if (uri == null) { Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo); } else {// w w w. j a v a 2 s . c o m Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); // Make sure the intent goes to the StockBrowser itself intent.setPackage(context.getPackageName()); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(SearchManager.QUERY, query); if (appData != null) { intent.putExtra(SearchManager.APP_DATA, appData); } if (extraData != null) { intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData); } intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); context.startActivity(intent); } }
From source file:com.android.browser.search.OpenSearchSearchEngine.java
public void startSearch(Context context, String query, Bundle appData, String extraData) { String uri = mSearchEngineInfo.getSearchUriForQuery(query); if (uri == null) { Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo); } else {/*from w w w . j av a2 s. c o m*/ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); // Make sure the intent goes to the Browser itself intent.setPackage(context.getPackageName()); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(SearchManager.QUERY, query); if (appData != null) { intent.putExtra(SearchManager.APP_DATA, appData); } if (extraData != null) { intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData); } intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); context.startActivity(intent); } }
From source file:com.borqs.browser.search.OpenSearchSearchEngine.java
public void startSearch(Context context, String query, Bundle appData, String extraData) { Log.i("OpenSearchSearchEng", "startSearch, query: " + query); String uri = mSearchEngineInfo.getSearchUriForQuery(query); if (uri == null) { Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo); } else {/*from w w w . jav a2 s .c o m*/ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); // Make sure the intent goes to the Browser itself intent.setPackage(context.getPackageName()); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(SearchManager.QUERY, query); if (appData != null) { intent.putExtra(SearchManager.APP_DATA, appData); } if (extraData != null) { intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData); } intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); context.startActivity(intent); } }
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);// w ww. ja va2 s . c o 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:io.github.pwlin.cordova.plugins.fileopener2.FileOpener2.java
private void _open(String fileArg, String contentType, CallbackContext callbackContext) throws JSONException { String fileName = ""; try {// w ww .j av a2 s.c o m CordovaResourceApi resourceApi = webView.getResourceApi(); Uri fileUri = resourceApi.remapUri(Uri.parse(fileArg)); fileName = this.stripFileProtocol(fileUri.toString()); } catch (Exception e) { fileName = fileArg; } File file = new File(fileName); if (file.exists()) { try { Uri path = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); if (Build.VERSION.SDK_INT >= 24) { Context context = cordova.getActivity().getApplicationContext(); path = FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".opener.provider", file); intent.setDataAndType(path, contentType); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); List<ResolveInfo> infoList = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : infoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, path, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } } else { intent.setDataAndType(path, contentType); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); } /* * @see * http://stackoverflow.com/questions/14321376/open-an-activity-from-a-cordovaplugin */ cordova.getActivity().startActivity(intent); //cordova.getActivity().startActivity(Intent.createChooser(intent,"Open File in...")); callbackContext.success(); } catch (android.content.ActivityNotFoundException e) { JSONObject errorObj = new JSONObject(); errorObj.put("status", PluginResult.Status.ERROR.ordinal()); errorObj.put("message", "Activity not found: " + e.getMessage()); callbackContext.error(errorObj); } } else { JSONObject errorObj = new JSONObject(); errorObj.put("status", PluginResult.Status.ERROR.ordinal()); errorObj.put("message", "File not found"); callbackContext.error(errorObj); } }
From source file:im.delight.android.commons.Social.java
/** * Opens the specified user's Facebook profile, either in the app or on the web * * @param context a context reference//from w ww . j a v a 2s. c om * @param facebookId the user's Facebook ID or profile name */ public static void openFacebookProfile(final Context context, final String facebookId) { Intent intent; try { // throws exception if not installed context.getPackageManager().getPackageInfo("com.facebook.katana", 0); intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + facebookId)); } catch (Exception e) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + facebookId)); } try { context.startActivity(intent); } catch (Exception e) { } }
From source file:com.pwned.steamfriends.views.TwitterStream.java
@Override public void onCreate(Bundle savedInstanceState) { setMyTheme();/*from w ww .j a v a2 s . c o m*/ super.onCreate(savedInstanceState); tracker = GoogleAnalyticsTracker.getInstance(); tracker.start(Constants.UACODE, 20, this); tracker.trackPageView("/TwitterStream"); mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mManager.cancel(APP_ID); setContentView(R.layout.twitter); m_streams = new ArrayList<Stream>(); this.m_adapter = new TwitterStreamAdapter(this, R.layout.row, m_streams); setListAdapter(this.m_adapter); viewStream = new Thread() { @Override public void run() { getStream(); } }; Animation a = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); a.setRepeatMode(Animation.RESTART); a.setRepeatCount(Animation.INFINITE); a.setDuration(750); a.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.linear_interpolator)); ivLoad = (ImageView) findViewById(R.id.loading_spinner); ivLoad.startAnimation(a); Thread thread = new Thread(null, viewStream, "SpecialsBackground"); thread.start(); //m_ProgressDialog = ProgressDialog.show(TwitterStream.this,"","Loading Twitter Stream...", true); steamHeader = (ImageView) findViewById(R.id.headerimage); steamHeader.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.HEADER_URL)); startActivity(myIntent); } }); }
From source file:bolts.AppLinkTest.java
public void testSimpleIntentWithAppLink() throws Exception { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); Bundle appLinkData = new Bundle(); appLinkData.putString("target_url", "http://www.example2.com"); appLinkData.putInt("version", 1); Bundle extras = new Bundle(); extras.putString("foo", "bar"); appLinkData.putBundle("extras", extras); i.putExtra("al_applink_data", appLinkData); assertEquals(Uri.parse("http://www.example2.com"), AppLinks.getTargetUrl(i)); assertNotNull(AppLinks.getAppLinkData(i)); assertNotNull(AppLinks.getAppLinkExtras(i)); assertEquals("bar", AppLinks.getAppLinkExtras(i).getString("foo")); }