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.cbtec.eliademy.EliademyLms.java
/** * Executes the request./*from www . ja v a2s . c o m*/ * * This method is called from the WebView thread. To do a non-trivial amount * of work, use: cordova.getThreadPool().execute(runnable); * * To run on the UI thread, use: * cordova.getActivity().runOnUiThread(runnable); * * @param action * The action to execute. * @param rawArgs * The exec() arguments in JSON form. * @param callbackContext * The callback context used when calling back into JavaScript. * @return Whether the action was valid. * @throws JSONException */ @Override public boolean execute(String action, JSONArray data, final CallbackContext callbackContext) throws JSONException { Log.i("HLMS", action); if ((action.compareTo("openfilesrv") == 0)) { try { Uri fileuri = Uri.parse(data.getString(0)); Intent intent = new Intent(Intent.ACTION_VIEW); String mimeextn = android.webkit.MimeTypeMap.getFileExtensionFromUrl(data.getString(0)); if (mimeextn.isEmpty()) { mimeextn = data.getString(0).substring(data.getString(0).indexOf(".") + 1); ; } String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(mimeextn); Log.i("HLMS", fileuri + " " + mimetype); intent.setDataAndType(fileuri, mimetype); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); cordova.getActivity().getApplicationContext().startActivity(intent); callbackContext.success(); } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(0); } return true; } else if ((action.compareTo("getfilesrv") == 0)) { this.mCallbackContext = callbackContext; cordova.getThreadPool().execute(new Runnable() { @Override public void run() { try { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*");// TODO: Restrict file types cordova.startActivityForResult(EliademyLms.this, intent, submitFileCode); } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(0); } return; } }); } else if ((action.compareTo("initservice") == 0)) { if (!mIsBound) { this.mCallbackContext = callbackContext; JSONObject tmp = new JSONObject(data.getString(0)); String sname = tmp.getString("servicename"); if (sname.contains("eliademy")) { mServiceName = "com.cbtec.serviceeliademy"; } else { // From url determine version 2.2, 2.3, 2.4 and change mServiceName = "com.cbtec.service" + sname; } Log.i("HLMS", "Connecting to service: " + mServiceName); doBindService(); } else { callbackContext.success(); } return true; } else { final String aAction = action; final JSONArray aData = data; String mappedCmd = null; try { mappedCmd = mapExecCommand(aData.getString(0)); } catch (JSONException e) { Log.e("HLMS", "exception", e); } if (mappedCmd == null) { Log.i("HLMS", "LMS service call failed " + mappedCmd); callbackContext.error(0);// TODO : error enum return false; } final String execCmd = mappedCmd; cordova.getThreadPool().execute(new Runnable() { @Override @SuppressLint("NewApi") public void run() { Log.i("HLMS", "Runner execute " + aAction + aData.toString()); if (aAction.compareTo("lmsservice") == 0) { try { String retval = null; Log.i("HLMS", "Execute cmd: " + execCmd); if (execCmd.compareTo("initialize") == 0) { if (mIBinder.initializeService(aData.getString(1))) { String token = mIBinder.eliademyGetWebServiceToken(); callbackContext.success(token); return; } } else if (execCmd.compareTo("deinitialize") == 0) { if (mIBinder.deInitializeService(aData.getString(1))) { doUnbindService(); callbackContext.success(); return; } } else if (execCmd.compareTo("pushregister") == 0) { Log.i("pushdata", aData.getString(1)); if (mIBinder.registerPushNotifications(aData.getString(1))) { callbackContext.success(); return; } } else if (execCmd.compareTo("pushunregister") == 0) { Log.i("pushdata", aData.getString(1)); if (mIBinder.unregisterPushNotifications(aData.getString(1))) { callbackContext.success(); return; } } else if (execCmd.compareTo("servicetoken") == 0) { retval = mIBinder.eliademyGetWebServiceToken(); } else if (execCmd.compareTo("siteinfo") == 0) { retval = mIBinder.eliademyGetSiteInformation(aData.getString(1)); } else if (execCmd.compareTo("get_user_courses") == 0) { retval = mIBinder.eliademyGetUsersCourses(aData.getString(1)); } else if (execCmd.compareTo("get_user_forums") == 0) { retval = mIBinder.eliademyGetUserForums(aData.getString(1)); } else if (execCmd.compareTo("get_user_info") == 0) { retval = mIBinder.eliademyGetUserInformation(aData.getString(1)); } else if (execCmd.compareTo("exec_webservice") == 0) { Log.i("HLMS", "Execute webservice"); retval = mIBinder.eliademyExecWebService(aData.getString(0), aData.getString(1)); } else if (execCmd.compareTo("course_get_contents") == 0) { retval = mIBinder.eliademyGetCourseContents(aData.getString(1)); } else if (execCmd.compareTo("course_get_enrolled_users") == 0) { retval = mIBinder.eliademyGetEnrolledUsers(aData.getString(1)); } else { Log.i("HLMS", "LMS service failed " + execCmd); callbackContext.error(0);// TODO : error enum } if (!retval.isEmpty()) { Log.i("HLMS", "LMS service call success"); callbackContext.success(retval); } else { Log.i("HLMS", "LMS service call failed"); callbackContext.error(0);// TODO : error enum } } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(e.getMessage()); return; } } else { Log.i("LMS", "Unsupported action call !!"); callbackContext.error(0); return; } } }); } return true; }
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);// www . 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; } } }
From source file:org.umit.icm.mobile.social.TwitterUpdate.java
/** * Requests a new Token. /* w ww. ja v a2 s .c o m*/ * * @param context An object of type {@link Context} * @see Intent */ public synchronized void requestToken(Context context) throws TwitterException, IOException, HttpException { requestToken = twitter.getOAuthRequestToken(); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthorizationURL())); context.startActivity(browserIntent); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.LocationObj.java
@Override public void activate(Context context, SignedObj obj) { JSONObject content = obj.getJson();//w w w . j av a 2 s.co m String loc = "geo:" + content.optDouble(COORD_LAT) + "," + content.optDouble(COORD_LONG) + "?z=17"; Intent map = new Intent(Intent.ACTION_VIEW, Uri.parse(loc)); context.startActivity(map); }
From source file:com.fastbootmobile.rssdemo.PushReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "ACTION : " + intent.getAction()); // Debug log the intent "action" // Get the shared preferences for OwnPush keys SharedPreferences pref = context.getApplicationContext().getSharedPreferences(OwnPushClient.PREF_PUSH, Context.MODE_PRIVATE); if (intent.getAction().equals(OwnPushClient.INTENT_RECEIVE)) { // This is a push message Log.d(TAG, "Decrypt : " + intent.getExtras().getString(OwnPushClient.EXTRA_DATA)); OwnPushCrypto fp = new OwnPushCrypto(); // Create a crypto object for decrypt // Get the app key pair from shared preferences (these have been confirmed by the register intent) OwnPushCrypto.AppKeyPair keys = fp.getKey(pref.getString(OwnPushClient.PREF_PUBLIC_KEY, ""), pref.getString(OwnPushClient.PREF_PRIVATE_KEY, "")); // Decrypt the message from the intent extra data String msg = fp.decryptFromIntent(intent.getExtras(), BuildConfig.APP_PUBLIC_KEY, keys); JSONObject jObj;/* ww w.jav a 2 s . c om*/ if (msg != null) { Log.e(TAG, "RSS : " + msg); try { // Decode the JOSN data in the message jObj = new JSONObject(msg); Intent i = new Intent(Intent.ACTION_VIEW); // Create the intent i.setData(Uri.parse(jObj.getString("link"))); // Set the data using URI (these are web links) // Convert to pending intent PendingIntent pIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), i, 0); // Create the notification Notification n = new Notification.Builder(context.getApplicationContext()) .setContentTitle("OwnPush RSS") // Main Title .setContentText(jObj.getString("title")) // Set content .setContentIntent(pIntent) // Add the pending intent .setSmallIcon(R.drawable.ic_done).setAutoCancel(true) // Remove notification if opened .build(); n.defaults |= Notification.DEFAULT_SOUND; // Make some noise on push // Get the notification manager and display notification NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(notification_num, n); // Increase the notification counter by 1 notification_num++; } catch (Exception e) { return; } } } }
From source file:com.appnexus.opensdk.MRAIDImplementation.java
WebViewClient getWebViewClient() { return new WebViewClient() { @Override//from w ww . j a va 2 s. c o m public boolean shouldOverrideUrlLoading(WebView view, String url) { if (!url.startsWith("mraid:") && !url.startsWith("javascript:")) { Intent intent; if (owner.owner.getOpensNativeBrowser()) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); } else { intent = new Intent(owner.getContext(), BrowserActivity.class); intent.putExtra("url", url); } try { owner.getContext().startActivity(intent); } catch (ActivityNotFoundException e) { Clog.w(Clog.mraidLogTag, Clog.getString(R.string.opening_url_failed, url)); } return true; } else if (url.startsWith("mraid://")) { MRAIDImplementation.this.dispatch_mraid_call(url); return true; } // See if any native activities can handle the Url try { owner.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); // If it's an IAV, prevent it from closing if (owner.owner instanceof InterstitialAdView) { ((InterstitialAdView) (owner.owner)).interacted(); } return true; } catch (ActivityNotFoundException e) { return false; } } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { Clog.e(Clog.httpRespLogTag, Clog.getString(R.string.webclient_error, error.getPrimaryError(), error.toString())); } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingURL) { Clog.e(Clog.httpRespLogTag, Clog.getString(R.string.webclient_error, errorCode, description)); } @Override public void onPageFinished(WebView view, String url) { // Fire the ready event only once if (!readyFired) { view.loadUrl(String.format("javascript:window.mraid.util.setPlacementType('%s')", owner.owner.isBanner() ? "inline" : "interstitial")); view.loadUrl("javascript:window.mraid.util.setIsViewable(true)"); view.loadUrl("javascript:window.mraid.util.stateChangeEvent('default')"); view.loadUrl("javascript:window.mraid.util.readyEvent();"); // Store width and height for close() default_width = owner.getLayoutParams().width; default_height = owner.getLayoutParams().height; readyFired = true; } } }; }
From source file:com.ankit.touchreview.LoginActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.login);/* ww w. j av a2 s .c o m*/ mContext = this; mProcessing = new ProgressDialog(mContext); mProcessing.setCancelable(true); mProcessing.setMessage("Please Wait"); mProcessing.setTitle("Logging in"); mProcessing.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (logging_in) { Intent i = new Intent(LoginActivity.this, HomeActivity.class); startActivity(i); finish(); } } }); username = (TextView) findViewById(R.id.username); password = (TextView) findViewById(R.id.password); String token = Utility.getUserPrefernce(mContext, "token"); if (token != null && !"".equals(token)) { Intent i = new Intent(LoginActivity.this, HomeActivity.class); startActivity(i); finish(); } TextView thanking_text = (TextView) findViewById(R.id.thanking_text); thanking_text.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://touchtoreview.com/thankyou")); startActivity(myIntent); } }); }
From source file:edu.berkeley.boinc.adapter.NoticesListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final Notice listItem = entries.get(position); LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = vi.inflate(R.layout.notices_layout_listitem, null); ImageView ivIcon = (ImageView) v.findViewById(R.id.projectIcon); Bitmap icon = getIcon(position);// w w w .j av a 2 s .c o m // if available set icon, if not boinc logo if (icon == null) { ivIcon.setImageDrawable(getContext().getResources().getDrawable(R.drawable.boinc)); } else { ivIcon.setImageBitmap(icon); } TextView tvProjectName = (TextView) v.findViewById(R.id.projectName); tvProjectName.setText(listItem.project_name); TextView tvNoticeTitle = (TextView) v.findViewById(R.id.noticeTitle); tvNoticeTitle.setText(listItem.title); TextView tvNoticeContent = (TextView) v.findViewById(R.id.noticeContent); tvNoticeContent.setText(Html.fromHtml(listItem.description)); TextView tvNoticeTime = (TextView) v.findViewById(R.id.noticeTime); tvNoticeTime.setText(DateUtils.formatDate(new java.util.Date((long) listItem.create_time * 1000))); v.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Logging.DEBUG) Log.d(Logging.TAG, "noticeClick: " + listItem.link); if (listItem.link != null && !listItem.link.isEmpty()) { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(listItem.link)); activity.startActivity(i); } } }); return v; }
From source file:com.miz.functions.YoutubeTrailerSearch.java
@Override protected void onPostExecute(String result) { if (result != null) { if (YouTubeApiServiceUtil.isYouTubeApiServiceAvailable(mActivity) .equals(YouTubeInitializationResult.SUCCESS)) { Intent intent = YouTubeStandalonePlayer.createVideoIntent(mActivity, MizLib.getYouTubeApiKey(mActivity), MizLib.getYouTubeId(result), 0, false, true); mActivity.startActivity(intent); } else {//w w w .jav a2 s. c om Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(result)); } } else { Toast.makeText(mActivity, mActivity.getString(R.string.errorSomethingWentWrong), Toast.LENGTH_LONG) .show(); } }
From source file:org.urbanstew.SoundCloudBase.SoundCloudMainActivity.java
/** * Processes menu options./*ww w.ja va 2s . co m*/ */ public boolean onOptionsItemSelected(MenuItem item) { if (item == mView) startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(getString(R.string.SCB_issues_url)))); else if (item == mReport) startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(getString(R.string.SCB_new_issue_url)))); else if (item == mJoinGroup) startActivity(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse(getString(R.string.SCB_join_mailing_list_url)))); // else if(item == mSettingsMenuItem) // startActivity(new Intent(getApplication(), SettingsActivity.class)); else if (item == mManualMenuItem) startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(getString(R.string.SCB_manual_url)))); else return false; return true; }