List of usage examples for android.content Intent getType
public @Nullable String getType()
From source file:com.googlecode.android_scripting.jsonrpc.JsonBuilder.java
private static JSONObject buildJsonIntent(Intent data) throws JSONException { JSONObject result = new JSONObject(); result.put("data", data.getDataString()); result.put("type", data.getType()); result.put("extras", build(data.getExtras())); result.put("categories", build(data.getCategories())); result.put("action", data.getAction()); ComponentName component = data.getComponent(); if (component != null) { result.put("packagename", component.getPackageName()); result.put("classname", component.getClassName()); }//from ww w . j a v a2 s. c o m result.put("flags", data.getFlags()); return result; }
From source file:com.fanfou.app.opensource.util.IntentHelper.java
public static void logIntent(final String tag, final Intent intent) { if (intent == null) { return;/*w ww .j a v a 2 s.c o m*/ } final StringBuffer sb = new StringBuffer(); sb.append("\nAction:" + intent.getAction()); sb.append("\nData:" + intent.getData()); sb.append("\nDataStr:" + intent.getDataString()); sb.append("\nScheme:" + intent.getScheme()); sb.append("\nType:" + intent.getType()); final Bundle extras = intent.getExtras(); if ((extras != null) && !extras.isEmpty()) { for (final String key : extras.keySet()) { final Object value = extras.get(key); sb.append("\nEXTRA: {" + key + "::" + value + "}"); } } else { sb.append("\nNO EXTRAS"); } Log.i(tag, sb.toString()); }
From source file:com.wuman.androidimageloader.samples.BaseActivity.java
/** * Converts an intent into a {@link Bundle} suitable for use as fragment * arguments./*from w ww .j av a 2 s .c o m*/ */ public static Bundle intentToFragmentArguments(Intent intent) { Bundle arguments = new Bundle(); if (intent == null) { return arguments; } final Uri data = intent.getData(); if (data != null) { arguments.putParcelable("_uri", data); } final String action = intent.getAction(); if (action != null) { arguments.putString("_action", action); } final String mimeType = intent.getType(); if (mimeType != null) { arguments.putString("_mimetype", mimeType); } final Bundle extras = intent.getExtras(); if (extras != null) { arguments.putAll(intent.getExtras()); } return arguments; }
From source file:de.ub0r.android.smsdroid.SMSdroid.java
/** * Get an {@link OnClickListener} for stating an Activity for given {@link Intent}. * * @param context {@link Context}//from w ww. java2 s.co m * @param intent {@link Intent} * @return {@link OnClickListener} */ static OnClickListener getOnClickStartActivity(final Context context, final Intent intent) { if (intent == null) { return null; } return new OnClickListener() { @Override public void onClick(final View v) { try { context.startActivity(intent); } catch (ActivityNotFoundException e) { Log.w(TAG, "activity not found", e); Toast.makeText(context, "no activity for data: " + intent.getType(), Toast.LENGTH_LONG).show(); } } }; }
From source file:at.wada811.utils.IntentUtils.java
public static String dump(Intent intent) throws JSONException { JSONObject json = new JSONObject(); json.put("action", intent.getAction()); if (intent.getCategories() != null) { JSONArray categories = new JSONArray(); for (String category : intent.getCategories()) { categories.put(category);//from ww w . ja v a 2 s . c o m } json.put("category", categories); } json.put("type", intent.getType()); Bundle bundle = intent.getExtras(); if (bundle != null) { JSONObject extras = new JSONObject(); for (String key : bundle.keySet()) { extras.put(key, bundle.get(key)); } json.put("extras", extras); } return json.toString(4); }
From source file:org.linkdroid.WebhookPostService.java
public static Bundle newPostDataBundle(Intent originator) { Bundle bundle = new Bundle(); if (originator.getExtras() != null) { bundle.putAll(originator.getExtras()); }/* w w w .j a va2 s . c o m*/ // Sanitize the linkdroid extras from data bundle in case originating // intent extras set them. We do this for all linkdroid Extras except // for the SMS extras. bundle.remove(Extras.INTENT_ACTION); bundle.remove(Extras.INTENT_TYPE); bundle.remove(Extras.INTENT_CATEGORIES); bundle.remove(Extras.HMAC); bundle.remove(Extras.NONCE); bundle.remove(Extras.STREAM); bundle.remove(Extras.STREAM_HMAC); bundle.remove(Extras.STREAM_MIME_TYPE); bundle.remove(Extras.USER_INPUT); if (originator.getAction() != null) { bundle.putString(Extras.INTENT_ACTION, originator.getAction()); } if (originator.getType() != null) { bundle.putString(Extras.INTENT_TYPE, originator.getType()); } if (originator.getCategories() != null) { bundle.putString(Extras.INTENT_CATEGORIES, StringUtils.join(originator.getCategories(), " ")); } return bundle; }
From source file:at.metalab.donarsson.screeninvader.InvadeScreen.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (networkInfo.isConnected()) { //TODO: Check if we know a ScreenInvader on this network Intent intent = getIntent(); String type = intent.getType(); if (type.startsWith("text/")) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); Pattern pattern = Patterns.WEB_URL; Matcher matcher = pattern.matcher(text); while (matcher.find()) { String url = matcher.group(); new PostUrlTask().execute(url); }//www.j ava 2 s . c o m } //TODO: Add support for other types (file upload) } else { //TODO: Display a prompt to connect to a WiFi Toast.makeText(getApplicationContext(), getString(R.string.no_wifi_toast), Toast.LENGTH_LONG).show(); } finish(); }
From source file:com.pureexe.calinoius.environment.camera.activity.FragmentDisplayActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent(); String type = intent.getType(); String start = intent.getExtras().getString(Intent.EXTRA_TEXT); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(getFragmentReadableName(start)); if (type.equals("beepActivity")) { if (start.equals("EXIFreadFragment")) { getFragmentManager().beginTransaction().replace(R.id.container, new EXIFreadFragment()).commit(); } else if (start.equals("CompassFragment")) { getFragmentManager().beginTransaction().replace(R.id.container, new CompassFragment()).commit(); } else if (start.equals("SettingPreferenceFragment")) { getFragmentManager().beginTransaction().replace(R.id.container, new SettingPreferenceFragment()) .commit();// ww w. j a v a 2s . c o m } else if (start.equals("HelpFragment")) { getFragmentManager().beginTransaction().replace(R.id.container, new HelpFragment()).commit(); } else { Toast.makeText(getApplicationContext(), "Not Found Intent : " + start, Toast.LENGTH_SHORT).show(); finish(); } } }
From source file:com.activiti.android.platform.provider.transfer.ContentTransferManager.java
public static final AddContentRelatedRepresentation prepareTransfer(Intent resultData, AlfrescoFragment fr, String id, int type) { Uri uri = null;/*from w ww .j a v a 2 s .c om*/ if (resultData != null) { uri = resultData.getData(); Log.i("TAG", "uri: " + uri); // Detect if it comes from Alfresco ? if (AlfrescoIntegrator.STORAGE_ACCESS_PROVIDER.equals(uri.getAuthority())) { // It's alfresco ! // Let's see if it's possible to link... AddContentRelatedRepresentation content = prepareLink(fr, uri); if (content == null) { // Link is impossible we upload the document requestUpload(fr, uri, id, type, resultData.getType()); } else { // Link is possible. // Let's request the user on how to handle this uploadAs(fr, uri, content, id, type, resultData.getType()); } } else { // It's something else requestUpload(fr, uri, id, type, resultData.getType()); } } return null; }
From source file:org.sufficientlysecure.keychain.ui.EncryptFilesActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setFullScreenDialogClose(Activity.RESULT_OK, false); Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); ArrayList<Uri> uris = new ArrayList<>(); if (intent.getData() != null) { uris.add(intent.getData());/* w ww . j av a 2 s .com*/ } // When sending to OpenKeychain Encrypt via share menu if (Intent.ACTION_SEND.equals(action) && type != null) { // Files via content provider, override uri and action uris.clear(); uris.add(intent.<Uri>getParcelableExtra(Intent.EXTRA_STREAM)); } if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); } if (savedInstanceState == null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); EncryptFilesFragment encryptFragment = EncryptFilesFragment.newInstance(uris); transaction.replace(R.id.encrypt_file_container, encryptFragment); transaction.commit(); } }