Java Code Examples for android.content.Intent#getScheme()

The following examples show how to use android.content.Intent#getScheme() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From opencdk-appwidget with Apache License 2.0 6 votes vote down vote up
private void handleIntent() {
    final Intent intent = getIntent();
    if (intent != null) {
        String scheme = intent.getScheme();
        if (GConstants.SCHEME.equalsIgnoreCase(scheme)) {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    try {
                        Uri uri = intent.getData();
                        String className = uri.getQueryParameter("className");

                        Intent transferIntent = new Intent();
                        transferIntent.putExtras(intent);
                        transferIntent.setClassName(MainActivity.this, className);
                        startActivity(transferIntent);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }, 300);
        }
    }
}
 
Example 2
Source File: WebViewInterceptDialog.java    From TemplateAppProject with Apache License 2.0 5 votes vote down vote up
private String getScheme(String url) {
    try {
        Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
        return intent.getScheme();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    return "";
}
 
Example 3
Source File: MainActivity.java    From hash-checker with Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
    Intent intent = getIntent();
    String scheme = null;
    ClipData clipData = null;
    if (intent != null) {
        scheme = intent.getScheme();
        clipData = intent.getClipData();
    }
    Uri externalFileUri = null;
    if (clipData != null) {
        externalFileUri = clipData.getItemAt(0).getUri();
    }

    HashCalculatorFragment mainFragment = new HashCalculatorFragment();
    if (scheme != null && scheme.compareTo(ContentResolver.SCHEME_CONTENT) == 0) {
        mainFragment.setArguments(getConfiguredBundleWithDataUri(intent.getData()));
        SettingsHelper.setGenerateFromShareIntentMode(this, true);
    } else if (externalFileUri != null) {
        mainFragment.setArguments(getConfiguredBundleWithDataUri(externalFileUri));
        SettingsHelper.setGenerateFromShareIntentMode(this, true);
    } else {
        mainFragment.setArguments(getBundleForShortcutAction(intent.getAction()));
        SettingsHelper.setGenerateFromShareIntentMode(this, false);
    }

    showFragment(mainFragment);
}
 
Example 4
Source File: ShareAllChannelActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
private void resolveUri(Intent intent, Uri data) {
    String scheme = intent.getScheme();
    if (scheme != null && "letvclient".equalsIgnoreCase(scheme)) {
        String actionType = "";
        String appName = "";
        String title = "";
        String officialSite = "";
        String text = "";
        String imgUrl = "";
        String playUrl = "";
        String from = "";
        try {
            actionType = data.getQueryParameter("actionType");
            appName = data.getQueryParameter("appName");
            title = data.getQueryParameter("title");
            officialSite = data.getQueryParameter("officialSite");
            text = data.getQueryParameter("text");
            imgUrl = data.getQueryParameter("imgUrl");
            playUrl = data.getQueryParameter("playUrl");
            from = data.getQueryParameter("from");
            packageName = data.getQueryParameter("package");
            invoker = data.getQueryParameter("invoker");
            LogInfo.log("fornia", "ShareAllChannelActivity  getIntent()" + actionType + "|" + appName + "|" + title + "|" + officialSite + "|" + text + "|" + imgUrl + "|" + playUrl + "|" + packageName + "|" + invoker + "|" + from);
            share2Channel(actionType, appName, title, officialSite, text, imgUrl, playUrl, from);
        } catch (NullPointerException e) {
            LogInfo.log("fornia", "NullPointerException e:" + e.getMessage() + "|" + e.toString());
            ToastUtils.showToast(getString(2131100833));
        } catch (Exception e2) {
            ToastUtils.showToast("三方传入参数未知错误,停止分享!");
            LogInfo.log("fornia", "Exception e:" + e2.getMessage() + "|" + e2.toString());
        }
    }
}
 
Example 5
Source File: MainActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
private void animEndProcess() {
    this.mMainShow = true;
    getWindow().clearFlags(1024);
    if (VERSION.SDK_INT >= 19) {
        getWindow().addFlags(67108864);
    }
    LogInfo.log("bootPic", "animate end");
    this.contentView.setVisibility(0);
    getWindow().setBackgroundDrawableResource(2131493324);
    this.animationIsFinish = true;
    this.imageLayout.setVisibility(8);
    Intent intent = getIntent();
    Uri data = intent.getData();
    if (data != null) {
        String scheme = intent.getScheme();
        if (scheme != null && SearchMainActivity.LESO_FROM.equalsIgnoreCase(scheme)) {
            if (!isFromThirdParty(data.getQueryParameter("from"))) {
                return;
            }
            return;
        }
    }
    if (!this.initTashIsSuccess || this.mIsFromPush || this.mLaunchByPush || this.mIsForceLaunch) {
        getHomeFragment().setHomeRecordVisible(true);
    } else {
        initPopDialog();
    }
    this.isAnimationIsFinish = true;
}
 
Example 6
Source File: DynamicApkManager.java    From Android-plugin-support with MIT License 5 votes vote down vote up
public List<ResolveInfo> queryIntentFromList(Intent intent, String resolvedType,
                                       ArrayList<DynamicApkParser.ActivityIntentInfo[]> listCut) {
    ArrayList<ResolveInfo> resultList = new ArrayList();

    FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
    final String scheme = intent.getScheme();
    int N = listCut.size();
    for (int i = 0; i < N; ++i) {
        buildResolveList(intent, categories,
                resolvedType, scheme, listCut.get(i), resultList);
    }

    sortResults(resultList);
    return resultList;
}
 
Example 7
Source File: LitePlayerStartActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
private void initLite(final Intent intent, boolean isCreate) {
    String scheme = intent.getScheme();
    if (!TextUtils.isEmpty(scheme) && AlbumLaunchUtils.LITESCHEME.equalsIgnoreCase(scheme)) {
        this.isLitePlayer = true;
        AlbumLaunchUtils.initLite(this, intent);
        ApkManager.getInstance().setLiteAppCallState(true);
        if (ApkManager.getInstance().getPluginInstallState("com.letv.android.lite") != 1) {
            UIsUtils.setScreenLandscape(this);
            if (isCreate) {
                setContentView(2130903057);
            }
            LetvApplication.getInstance().mCallLiteIntent = intent;
            JarUtil.updatePlugin(this, 1, true);
        } else if (LetvApplication.getInstance().mIsPluginInitedSuccess) {
            JarLaunchUtils.launchLitePlayerDefault(this, intent);
        } else {
            PluginInitedCallback.mPluginInitedListener = new OnPluginInitedListener(this) {
                final /* synthetic */ LitePlayerStartActivity this$0;

                public void onInited() {
                    JarLaunchUtils.launchLitePlayerDefault(this.this$0.mContext, intent);
                }
            };
        }
    } else if (isCreate) {
        setContentView(2130903068);
    }
}
 
Example 8
Source File: DynamicApkManager.java    From Android-plugin-support with MIT License 5 votes vote down vote up
public List<ResolveInfo> queryIntentFromList(Intent intent, String resolvedType,
                                       ArrayList<DynamicApkParser.ServiceIntentInfo[]> listCut) {
    ArrayList<ResolveInfo> resultList = new ArrayList();

    FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
    final String scheme = intent.getScheme();
    int N = listCut.size();
    for (int i = 0; i < N; ++i) {
        buildResolveList(intent, categories,
                resolvedType, scheme, listCut.get(i), resultList);
    }

    sortResults(resultList);
    return resultList;
}
 
Example 9
Source File: AddContactActivity.java    From Zom-Android-XMPP with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    super.onCreate(savedInstanceState);

    setTitle("");

    mApp = (ImApp)getApplication();

    mHandler = new SimpleAlertHandler(this);

    setContentView(R.layout.add_contact_activity);

    TextView label = (TextView) findViewById(R.id.input_contact_label);
    label.setText(getString(R.string.enter_your_friends_account, mApp.getDefaultUsername()));

    mNewAddress = (EditText) findViewById(R.id.email);
    mNewAddress.addTextChangedListener(mTextWatcher);

    mNewAddress.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {

                inviteBuddies();
            }
            return false;
        }
    });

    Intent intent = getIntent();
    String scheme = intent.getScheme();
    if (TextUtils.equals(scheme, "xmpp"))
    {
        addContactFromUri(intent.getData());
    }

    setupActions ();

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

}
 
Example 10
Source File: LocalBroadcastManager.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Broadcast the given intent to all interested BroadcastReceivers.  This
 * call is asynchronous; it returns immediately, and you will continue
 * executing while the receivers are run.
 *
 * @param intent The Intent to broadcast; all receivers matching this
 *     Intent will receive the broadcast.
 *
 * @see #registerReceiver
 */
public boolean sendBroadcast(Intent intent) {
    synchronized (mReceivers) {
        final String action = intent.getAction();
        final String type = intent.resolveTypeIfNeeded(
                mAppContext.getContentResolver());
        final Uri data = intent.getData();
        final String scheme = intent.getScheme();
        final Set<String> categories = intent.getCategories();

        final boolean debug = DEBUG ||
                ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
        if (debug) Log.v(
                TAG, "Resolving type " + type + " scheme " + scheme
                + " of intent " + intent);

        ArrayList<ReceiverRecord> entries = mActions.get(intent.getAction());
        if (entries != null) {
            if (debug) Log.v(TAG, "Action list: " + entries);

            ArrayList<ReceiverRecord> receivers = null;
            for (int i=0; i<entries.size(); i++) {
                ReceiverRecord receiver = entries.get(i);
                if (debug) Log.v(TAG, "Matching against filter " + receiver.filter);

                if (receiver.broadcasting) {
                    if (debug) {
                        Log.v(TAG, "  Filter's target already added");
                    }
                    continue;
                }

                int match = receiver.filter.match(action, type, scheme, data,
                        categories, "LocalBroadcastManager");
                if (match >= 0) {
                    if (debug) Log.v(TAG, "  Filter matched!  match=0x" +
                            Integer.toHexString(match));
                    if (receivers == null) {
                        receivers = new ArrayList<ReceiverRecord>();
                    }
                    receivers.add(receiver);
                    receiver.broadcasting = true;
                } else {
                    if (debug) {
                        String reason;
                        switch (match) {
                            case IntentFilter.NO_MATCH_ACTION: reason = "action"; break;
                            case IntentFilter.NO_MATCH_CATEGORY: reason = "category"; break;
                            case IntentFilter.NO_MATCH_DATA: reason = "data"; break;
                            case IntentFilter.NO_MATCH_TYPE: reason = "type"; break;
                            default: reason = "unknown reason"; break;
                        }
                        Log.v(TAG, "  Filter did not match: " + reason);
                    }
                }
            }

            if (receivers != null) {
                for (int i=0; i<receivers.size(); i++) {
                    receivers.get(i).broadcasting = false;
                }
                mPendingBroadcasts.add(new BroadcastRecord(intent, receivers));
                if (!mHandler.hasMessages(MSG_EXEC_PENDING_BROADCASTS)) {
                    mHandler.sendEmptyMessage(MSG_EXEC_PENDING_BROADCASTS);
                }
                return true;
            }
        }
    }
    return false;
}
 
Example 11
Source File: IntentMatcherHelper.java    From springreplugin with Apache License 2.0 4 votes vote down vote up
/**
 * 根据 Intent 匹配组件
 *
 * @param context    Context
 * @param intent     调用方传来的 Intent
 * @param filtersMap 插件中声明的所有组件和 IntentFilter
 * @return ComponentInfo
 */
public static String doMatchIntent(Context context, Intent intent, Map<String, List<IntentFilter>> filtersMap) {
    if (filtersMap == null) {
        return null;
    }

    final String action = intent.getAction();
    final String type = intent.resolveTypeIfNeeded(context.getContentResolver());
    final Uri data = intent.getData();
    final String scheme = intent.getScheme();
    final Set<String> categories = intent.getCategories();

    for (Map.Entry<String, List<IntentFilter>> entry : filtersMap.entrySet()) {
        String pluginName = entry.getKey();
        List<IntentFilter> filters = entry.getValue();
        if (filters == null) {
            continue;
        }

        for (IntentFilter filter : filters) {
            int match = filter.match(action, type, scheme, data, categories, "ComponentList");
            if (match >= 0) {
                if (LOG) {
                    LogDebug.d(TAG, "IntentFilter 匹配成功: " + entry.getKey());
                }
                return pluginName;
            } else {
                if (LOG) {
                    String reason;
                    switch (match) {
                        case IntentFilter.NO_MATCH_ACTION:
                            reason = "action";
                            break;
                        case IntentFilter.NO_MATCH_CATEGORY:
                            reason = "category";
                            break;
                        case IntentFilter.NO_MATCH_DATA:
                            reason = "data";
                            break;
                        case IntentFilter.NO_MATCH_TYPE:
                            reason = "type";
                            break;
                        default:
                            reason = "unknown reason";
                            break;
                    }
                    LogDebug.d(TAG, "  Filter did not match: " + reason);
                }
            }
        }
    }
    return "";
}
 
Example 12
Source File: PluginLocalBroadcastManager.java    From springreplugin with Apache License 2.0 4 votes vote down vote up
/**
 * Broadcast the given intent to all interested BroadcastReceivers.  This
 * call is asynchronous; it returns immediately, and you will continue
 * executing while the receivers are run.
 *
 * @param intent The Intent to broadcast; all receivers matching this
 *     Intent will receive the broadcast.
 *
 * @see #registerReceiver
 */
public boolean sendBroadcast(Intent intent) {
    if (RePluginFramework.mHostInitialized) {
        try {
            return (Boolean) ProxyLocalBroadcastManagerVar.sendBroadcast.call(sOrigInstance, intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    synchronized (mReceivers) {
        final String action = intent.getAction();
        final String type = intent.resolveTypeIfNeeded(
                mAppContext.getContentResolver());
        final Uri data = intent.getData();
        final String scheme = intent.getScheme();
        final Set<String> categories = intent.getCategories();

        final boolean debug = DEBUG ||
                ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
        if (debug) {
            Log.v(
                    TAG, "Resolving type " + type + " scheme " + scheme
                            + " of intent " + intent);
        }

        ArrayList<ReceiverRecord> entries = mActions.get(intent.getAction());
        if (entries != null) {
            if (debug) {
                Log.v(TAG, "Action list: " + entries);
            }

            ArrayList<ReceiverRecord> receivers = null;
            for (int i=0; i<entries.size(); i++) {
                ReceiverRecord receiver = entries.get(i);
                if (debug) {
                    Log.v(TAG, "Matching against filter " + receiver.filter);
                }

                if (receiver.broadcasting) {
                    if (debug) {
                        Log.v(TAG, "  Filter's target already added");
                    }
                    continue;
                }

                int match = receiver.filter.match(action, type, scheme, data,
                        categories, "PluginLocalBroadcastManager");
                if (match >= 0) {
                    if (debug) {
                        Log.v(TAG, "  Filter matched!  match=0x" +
                                Integer.toHexString(match));
                    }
                    if (receivers == null) {
                        receivers = new ArrayList<ReceiverRecord>();
                    }
                    receivers.add(receiver);
                    receiver.broadcasting = true;
                } else {
                    if (debug) {
                        String reason;
                        switch (match) {
                            case IntentFilter.NO_MATCH_ACTION: reason = "action"; break;
                            case IntentFilter.NO_MATCH_CATEGORY: reason = "category"; break;
                            case IntentFilter.NO_MATCH_DATA: reason = "data"; break;
                            case IntentFilter.NO_MATCH_TYPE: reason = "type"; break;
                            default: reason = "unknown reason"; break;
                        }
                        Log.v(TAG, "  Filter did not match: " + reason);
                    }
                }
            }

            if (receivers != null) {
                for (int i=0; i<receivers.size(); i++) {
                    receivers.get(i).broadcasting = false;
                }
                mPendingBroadcasts.add(new BroadcastRecord(intent, receivers));
                if (!mHandler.hasMessages(MSG_EXEC_PENDING_BROADCASTS)) {
                    mHandler.sendEmptyMessage(MSG_EXEC_PENDING_BROADCASTS);
                }
                return true;
            }
        }
    }
    return false;
}
 
Example 13
Source File: RouterActivity.java    From Zom-Android-XMPP with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mApp = (ImApp)getApplication();

    mHandler = new MyHandler(this);

    Intent intent = getIntent();

    mDoLock = ACTION_LOCK_APP.equals(intent.getAction());

    if (mDoLock) {
        shutdownAndLock(this);

        return;
    } else if (Panic.isTriggerIntent(intent)) {
        if (PanicResponder.receivedTriggerFromConnectedApp(this)) {
            if (Preferences.uninstallApp()) {
                // lock and delete first for rapid response, then uninstall
                shutdownAndLock(this);
                PanicResponder.deleteAllAppData(this);
                Intent uninstall = new Intent(Intent.ACTION_DELETE);
                uninstall.setData(Uri.parse("package:" + getPackageName()));
                startActivity(uninstall);
            } else if (Preferences.clearAppData()) {
                // lock first for rapid response, then delete
                shutdownAndLock(this);
                PanicResponder.deleteAllAppData(this);
            } else if (Preferences.lockApp()) {
                shutdownAndLock(this);
            }
            // TODO add other responses here, paying attention to if/else order
        } else if (PanicResponder.shouldUseDefaultResponseToTrigger(this)) {
            if (Preferences.lockApp()) {
                shutdownAndLock(this);
            }
        }
        // this Intent should not trigger any more processing
        finish();
        return;
    }

    mSignInHelper = new SignInHelper(this, mHandler);
    mDoSignIn = intent.getBooleanExtra(EXTRA_DO_SIGNIN, true);

    AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);

    mCacheWord = new CacheWordHandler(this, (ICacheWordSubscriber)this);
    mCacheWord.connectToService();

    // if we have an incoming contact, send it to the right place
    String scheme = intent.getScheme();
    if(TextUtils.equals(scheme, "xmpp"))
    {
        intent.setClass(this, AddContactActivity.class);
        startActivity(intent);
        finish();
        return;
    }
}
 
Example 14
Source File: LocalBroadcastManager.java    From Dashchan with Apache License 2.0 4 votes vote down vote up
/**
 * Broadcast the given intent to all interested BroadcastReceivers. This call is asynchronous; it returns
 * immediately, and you will continue executing while the receivers are run.
 *
 * @param intent
 *            The Intent to broadcast; all receivers matching this Intent will receive the broadcast.
 *
 * @see #registerReceiver
 */
public boolean sendBroadcast(Intent intent) {
	synchronized (mReceivers) {
		final String action = intent.getAction();
		final String type = intent.resolveTypeIfNeeded(MainApplication.getInstance().getContentResolver());
		final Uri data = intent.getData();
		final String scheme = intent.getScheme();
		final Set<String> categories = intent.getCategories();

		ArrayList<ReceiverRecord> entries = mActions.get(intent.getAction());
		if (entries != null) {
			ArrayList<ReceiverRecord> receivers = null;
			for (int i = 0; i < entries.size(); i++) {
				ReceiverRecord receiver = entries.get(i);
				if (receiver.broadcasting) {
					continue;
				}

				int match = receiver.filter.match(action, type, scheme, data, categories, "LocalBroadcastManager");
				if (match >= 0) {
					if (receivers == null) {
						receivers = new ArrayList<>();
					}
					receivers.add(receiver);
					receiver.broadcasting = true;
				}
			}

			if (receivers != null) {
				for (int i = 0; i < receivers.size(); i++) {
					receivers.get(i).broadcasting = false;
				}
				mPendingBroadcasts.add(new BroadcastRecord(intent, receivers));
				if (!mHandler.hasMessages(MSG_EXEC_PENDING_BROADCASTS)) {
					mHandler.sendEmptyMessage(MSG_EXEC_PENDING_BROADCASTS);
				}
				return true;
			}
		}
	}
	return false;
}
 
Example 15
Source File: LocalBroadcastManager.java    From koala--Android-Plugin-Runtime- with Apache License 2.0 4 votes vote down vote up
/**
 * Broadcast the given intent to all interested BroadcastReceivers. This
 * call is asynchronous; it returns immediately, and you will continue
 * executing while the receivers are run.
 * 
 * @param intent
 *            The Intent to broadcast; all receivers matching this Intent
 *            will receive the broadcast.
 * 
 * @see #registerReceiver
 */
public boolean sendBroadcast(Intent intent) {
	synchronized (mReceivers) {
		final String action = intent.getAction();
		final String type = intent.resolveTypeIfNeeded(mAppContext
				.getContentResolver());
		final Uri data = intent.getData();
		final String scheme = intent.getScheme();
		final Set<String> categories = intent.getCategories();

		final boolean debug = DEBUG
				|| ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
		if (debug)
			Log.v(TAG, "Resolving type " + type + " scheme " + scheme
					+ " of intent " + intent);

		ArrayList<ReceiverRecord> entries = mActions
				.get(intent.getAction());
		if (entries != null) {
			if (debug)
				Log.v(TAG, "Action list: " + entries);

			ArrayList<ReceiverRecord> receivers = null;
			for (int i = 0; i < entries.size(); i++) {
				ReceiverRecord receiver = entries.get(i);
				if (debug)
					Log.v(TAG, "Matching against filter " + receiver.filter);

				if (receiver.broadcasting) {
					if (debug) {
						Log.v(TAG, "  Filter's target already added");
					}
					continue;
				}

				int match = receiver.filter.match(action, type, scheme,
						data, categories, "LocalBroadcastManager");
				if (match >= 0) {
					if (debug)
						Log.v(TAG,
								"  Filter matched!  match=0x"
										+ Integer.toHexString(match));
					if (receivers == null) {
						receivers = new ArrayList<ReceiverRecord>();
					}
					receivers.add(receiver);
					receiver.broadcasting = true;
				} else {
					if (debug) {
						String reason;
						switch (match) {
						case IntentFilter.NO_MATCH_ACTION:
							reason = "action";
							break;
						case IntentFilter.NO_MATCH_CATEGORY:
							reason = "category";
							break;
						case IntentFilter.NO_MATCH_DATA:
							reason = "data";
							break;
						case IntentFilter.NO_MATCH_TYPE:
							reason = "type";
							break;
						default:
							reason = "unknown reason";
							break;
						}
						Log.v(TAG, "  Filter did not match: " + reason);
					}
				}
			}

			if (receivers != null) {
				for (int i = 0; i < receivers.size(); i++) {
					receivers.get(i).broadcasting = false;
				}
				mPendingBroadcasts.add(new BroadcastRecord(intent,
						receivers));
				if (!mHandler.hasMessages(MSG_EXEC_PENDING_BROADCASTS)) {
					mHandler.sendEmptyMessage(MSG_EXEC_PENDING_BROADCASTS);
				}
				return true;
			}
		}
	}
	return false;
}
 
Example 16
Source File: MeasurementEvent.java    From letv with Apache License 2.0 4 votes vote down vote up
private static Bundle getApplinkLogData(Context context, String eventName, Bundle appLinkData, Intent applinkIntent) {
    Bundle logData = new Bundle();
    ComponentName resolvedActivity = applinkIntent.resolveActivity(context.getPackageManager());
    if (resolvedActivity != null) {
        logData.putString("class", resolvedActivity.getShortClassName());
    }
    if (APP_LINK_NAVIGATE_OUT_EVENT_NAME.equals(eventName)) {
        if (resolvedActivity != null) {
            logData.putString("package", resolvedActivity.getPackageName());
        }
        if (applinkIntent.getData() != null) {
            logData.putString("outputURL", applinkIntent.getData().toString());
        }
        if (applinkIntent.getScheme() != null) {
            logData.putString("outputURLScheme", applinkIntent.getScheme());
        }
    } else if (APP_LINK_NAVIGATE_IN_EVENT_NAME.equals(eventName)) {
        if (applinkIntent.getData() != null) {
            logData.putString("inputURL", applinkIntent.getData().toString());
        }
        if (applinkIntent.getScheme() != null) {
            logData.putString("inputURLScheme", applinkIntent.getScheme());
        }
    }
    for (String key : appLinkData.keySet()) {
        Object o = appLinkData.get(key);
        String logValue;
        if (o instanceof Bundle) {
            for (String subKey : ((Bundle) o).keySet()) {
                logValue = objectToJSONString(((Bundle) o).get(subKey));
                if (key.equals("referer_app_link")) {
                    if (subKey.equalsIgnoreCase("url")) {
                        logData.putString("refererURL", logValue);
                    } else if (subKey.equalsIgnoreCase("app_name")) {
                        logData.putString("refererAppName", logValue);
                    } else if (subKey.equalsIgnoreCase("package")) {
                        logData.putString("sourceApplication", logValue);
                    }
                }
                logData.putString(key + "/" + subKey, logValue);
            }
        } else {
            logValue = objectToJSONString(o);
            if (key.equals("target_url")) {
                Uri targetURI = Uri.parse(logValue);
                logData.putString("targetURL", targetURI.toString());
                logData.putString("targetURLHost", targetURI.getHost());
            } else {
                logData.putString(key, logValue);
            }
        }
    }
    return logData;
}
 
Example 17
Source File: RouterActivity.java    From zom-android-matrix with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mApp = (ImApp)getApplication();

    mHandler = new MyHandler(this);

    Intent intent = getIntent();

    mDoLock = ACTION_LOCK_APP.equals(intent.getAction());

    if (mDoLock) {
        shutdownAndLock(this);

        return;
    } else if (Panic.isTriggerIntent(intent)) {
        if (PanicResponder.receivedTriggerFromConnectedApp(this)) {
            if (Preferences.uninstallApp()) {
                // lock and delete first for rapid response, then uninstall
                shutdownAndLock(this);
                PanicResponder.deleteAllAppData(this);
                Intent uninstall = new Intent(Intent.ACTION_DELETE);
                uninstall.setData(Uri.parse("package:" + getPackageName()));
                startActivity(uninstall);
            } else if (Preferences.clearAppData()) {
                // lock first for rapid response, then delete
                shutdownAndLock(this);
                PanicResponder.deleteAllAppData(this);
            } else if (Preferences.lockApp()) {
                shutdownAndLock(this);
            }
            // TODO add other responses here, paying attention to if/else order
        } else if (PanicResponder.shouldUseDefaultResponseToTrigger(this)) {
            if (Preferences.lockApp()) {
                shutdownAndLock(this);
            }
        }
        // this Intent should not trigger any more processing
        finish();
        return;
    }

    mSignInHelper = new SignInHelper(this, mHandler);
    mDoSignIn = intent.getBooleanExtra(EXTRA_DO_SIGNIN, false);

    AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);

    mCacheWord = new CacheWordHandler(this, (ICacheWordSubscriber)this);
    mCacheWord.connectToService();

    // if we have an incoming contact, send it to the right place
    String scheme = intent.getScheme();
    if(TextUtils.equals(scheme, "keanu"))
    {
        intent.setClass(this, AddContactActivity.class);
        startActivity(intent);
        finish();
        return;
    }

}
 
Example 18
Source File: LocalBroadcastManager.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
/**
 * Broadcast the given intent to all interested BroadcastReceivers.  This
 * call is asynchronous; it returns immediately, and you will continue
 * executing while the receivers are run.
 *
 * @param intent The Intent to broadcast; all receivers matching this
 *     Intent will receive the broadcast.
 *
 * @see #registerReceiver
 */
public boolean sendBroadcast(Intent intent) {
    synchronized (mReceivers) {
        final String action = intent.getAction();
        final String type = intent.resolveTypeIfNeeded(
                mAppContext.getContentResolver());
        final Uri data = intent.getData();
        final String scheme = intent.getScheme();
        final Set<String> categories = intent.getCategories();

        final boolean debug = DEBUG ||
                ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
        if (debug) Log.v(
                TAG, "Resolving type " + type + " scheme " + scheme
                + " of intent " + intent);

        ArrayList<ReceiverRecord> entries = mActions.get(intent.getAction());
        if (entries != null) {
            if (debug) Log.v(TAG, "Action list: " + entries);

            ArrayList<ReceiverRecord> receivers = null;
            for (int i=0; i<entries.size(); i++) {
                ReceiverRecord receiver = entries.get(i);
                if (debug) Log.v(TAG, "Matching against filter " + receiver.filter);

                if (receiver.broadcasting) {
                    if (debug) {
                        Log.v(TAG, "  Filter's target already added");
                    }
                    continue;
                }

                int match = receiver.filter.match(action, type, scheme, data,
                        categories, "LocalBroadcastManager");
                if (match >= 0) {
                    if (debug) Log.v(TAG, "  Filter matched!  match=0x" +
                            Integer.toHexString(match));
                    if (receivers == null) {
                        receivers = new ArrayList<ReceiverRecord>();
                    }
                    receivers.add(receiver);
                    receiver.broadcasting = true;
                } else {
                    if (debug) {
                        String reason;
                        switch (match) {
                            case IntentFilter.NO_MATCH_ACTION: reason = "action"; break;
                            case IntentFilter.NO_MATCH_CATEGORY: reason = "category"; break;
                            case IntentFilter.NO_MATCH_DATA: reason = "data"; break;
                            case IntentFilter.NO_MATCH_TYPE: reason = "type"; break;
                            default: reason = "unknown reason"; break;
                        }
                        Log.v(TAG, "  Filter did not match: " + reason);
                    }
                }
            }

            if (receivers != null) {
                for (int i=0; i<receivers.size(); i++) {
                    receivers.get(i).broadcasting = false;
                }
                mPendingBroadcasts.add(new BroadcastRecord(intent, receivers));
                if (!mHandler.hasMessages(MSG_EXEC_PENDING_BROADCASTS)) {
                    mHandler.sendEmptyMessage(MSG_EXEC_PENDING_BROADCASTS);
                }
                return true;
            }
        }
    }
    return false;
}
 
Example 19
Source File: IntentResolver.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public List<R> queryIntent(Intent intent, String resolvedType, boolean defaultOnly,
        int userId) {
    String scheme = intent.getScheme();

    ArrayList<R> finalList = new ArrayList<R>();

    final boolean debug = localLOGV ||
            ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);

    if (debug) Slog.v(
        TAG, "Resolving type=" + resolvedType + " scheme=" + scheme
        + " defaultOnly=" + defaultOnly + " userId=" + userId + " of " + intent);

    F[] firstTypeCut = null;
    F[] secondTypeCut = null;
    F[] thirdTypeCut = null;
    F[] schemeCut = null;

    // If the intent includes a MIME type, then we want to collect all of
    // the filters that match that MIME type.
    if (resolvedType != null) {
        int slashpos = resolvedType.indexOf('/');
        if (slashpos > 0) {
            final String baseType = resolvedType.substring(0, slashpos);
            if (!baseType.equals("*")) {
                if (resolvedType.length() != slashpos+2
                        || resolvedType.charAt(slashpos+1) != '*') {
                    // Not a wild card, so we can just look for all filters that
                    // completely match or wildcards whose base type matches.
                    firstTypeCut = mTypeToFilter.get(resolvedType);
                    if (debug) Slog.v(TAG, "First type cut: " + Arrays.toString(firstTypeCut));
                    secondTypeCut = mWildTypeToFilter.get(baseType);
                    if (debug) Slog.v(TAG, "Second type cut: "
                            + Arrays.toString(secondTypeCut));
                } else {
                    // We can match anything with our base type.
                    firstTypeCut = mBaseTypeToFilter.get(baseType);
                    if (debug) Slog.v(TAG, "First type cut: " + Arrays.toString(firstTypeCut));
                    secondTypeCut = mWildTypeToFilter.get(baseType);
                    if (debug) Slog.v(TAG, "Second type cut: "
                            + Arrays.toString(secondTypeCut));
                }
                // Any */* types always apply, but we only need to do this
                // if the intent type was not already */*.
                thirdTypeCut = mWildTypeToFilter.get("*");
                if (debug) Slog.v(TAG, "Third type cut: " + Arrays.toString(thirdTypeCut));
            } else if (intent.getAction() != null) {
                // The intent specified any type ({@literal *}/*).  This
                // can be a whole heck of a lot of things, so as a first
                // cut let's use the action instead.
                firstTypeCut = mTypedActionToFilter.get(intent.getAction());
                if (debug) Slog.v(TAG, "Typed Action list: " + Arrays.toString(firstTypeCut));
            }
        }
    }

    // If the intent includes a data URI, then we want to collect all of
    // the filters that match its scheme (we will further refine matches
    // on the authority and path by directly matching each resulting filter).
    if (scheme != null) {
        schemeCut = mSchemeToFilter.get(scheme);
        if (debug) Slog.v(TAG, "Scheme list: " + Arrays.toString(schemeCut));
    }

    // If the intent does not specify any data -- either a MIME type or
    // a URI -- then we will only be looking for matches against empty
    // data.
    if (resolvedType == null && scheme == null && intent.getAction() != null) {
        firstTypeCut = mActionToFilter.get(intent.getAction());
        if (debug) Slog.v(TAG, "Action list: " + Arrays.toString(firstTypeCut));
    }

    FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
    if (firstTypeCut != null) {
        buildResolveList(intent, categories, debug, defaultOnly, resolvedType,
                scheme, firstTypeCut, finalList, userId);
    }
    if (secondTypeCut != null) {
        buildResolveList(intent, categories, debug, defaultOnly, resolvedType,
                scheme, secondTypeCut, finalList, userId);
    }
    if (thirdTypeCut != null) {
        buildResolveList(intent, categories, debug, defaultOnly, resolvedType,
                scheme, thirdTypeCut, finalList, userId);
    }
    if (schemeCut != null) {
        buildResolveList(intent, categories, debug, defaultOnly, resolvedType,
                scheme, schemeCut, finalList, userId);
    }
    filterResults(finalList);
    sortResults(finalList);

    if (debug) {
        Slog.v(TAG, "Final result list:");
        for (int i=0; i<finalList.size(); i++) {
            Slog.v(TAG, "  " + finalList.get(i));
        }
    }
    return finalList;
}
 
Example 20
Source File: AddContactActivity.java    From zom-android-matrix with Apache License 2.0 2 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    super.onCreate(savedInstanceState);

    setTitle("");

    mApp = (ImApp)getApplication();

    long providerId = getIntent().getLongExtra(ContactsPickerActivity.EXTRA_RESULT_PROVIDER,mApp.getDefaultProviderId());
    long accountId = getIntent().getLongExtra(ContactsPickerActivity.EXTRA_RESULT_ACCOUNT,mApp.getDefaultAccountId());

    mConn = RemoteImService.getConnection(providerId, accountId);
    mHandler = new SimpleAlertHandler(this);

    setContentView(R.layout.add_contact_activity);

    TextView label = (TextView) findViewById(R.id.input_contact_label);
    label.setText(getString(R.string.enter_your_friends_account, mApp.getDefaultUsername()));

    mNewAddress = (EditText) findViewById(R.id.email);
    mNewAddress.addTextChangedListener(mTextWatcher);

    mNewAddress.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {

                addContact();
            }
            return false;
        }
    });


    setupActions ();

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();
    mAddLocalContact = intent.getBooleanExtra("addLocalContact",true);

    String scheme = intent.getScheme();

    if (TextUtils.equals(scheme, "matrix"))
    {
        addContactFromUri(intent.getData());
    }


    if (intent.hasExtra("username"))
    {
        String newContact = intent.getStringExtra("username");
        mNewAddress.setText(newContact);

    }

}