Java Code Examples for android.content.Intent.getFlags()

The following are Jave code examples for showing how to use getFlags() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: OpenLibre   File: MainActivity.java   View Source Code Vote up 7 votes
private void resolveIntent(Intent data) {
    this.setIntent(data);

    if ((data.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
        return;
    }

    if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(data.getAction())) {
        mLastNfcTag = data.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        long now = new Date().getTime();

        if (mContinuousSensorReadingFlag) {
            startContinuousSensorReadingTimer();

        } else if (now - mLastScanTime > 5000) {
            DataPlotFragment dataPlotFragment = (DataPlotFragment)
                    mSectionsPagerAdapter.getRegisteredFragment(R.integer.viewpager_page_show_scan);
            if (dataPlotFragment != null) {
                dataPlotFragment.clearScanData();
            }

            new NfcVReaderTask(this).execute(mLastNfcTag);
        }
    }
}
 
Example 2
Project: atlas   File: IntentResolver.java   View Source Code Vote up 7 votes
public List<R> queryIntentFromList(Intent intent, String resolvedType, 
        boolean defaultOnly, ArrayList<F[]> listCut) {
    ArrayList<R> resultList = new ArrayList<R>();

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

    FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
    final String scheme = intent.getScheme();
    int N = listCut.size();
    for (int i = 0; i < N; ++i) {
        buildResolveList(intent, categories, debug, defaultOnly,
                resolvedType, scheme, listCut.get(i), resultList);
    }
    sortResults(resultList);
    return resultList;
}
 
Example 3
Project: hypertrack-live-android   File: SplashScreen.java   View Source Code Vote up 6 votes
/**
 * Method to handle deeplink parameters received via intent
 */
private void handleAppDeepLink() {
    appDeepLink = new AppDeepLink(DeepLinkUtil.DEFAULT);

    // Extract deeplink params from the received intent
    Intent intent = getIntent();
    if (intent != null && !HTTextUtils.isEmpty(intent.getDataString())) {
        Log.d(TAG, "deeplink " + intent.getDataString());
        int flags = intent.getFlags();
        if ((flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
            return;
        }
        appDeepLink = DeepLinkUtil.prepareAppDeepLink(this, intent.getData());
    }
}
 
Example 4
Project: MiPushFramework   File: CondomContext.java   View Source Code Vote up 6 votes
@Override public ResolveInfo resolveService(final Intent intent, final int flags) {
	final int original_intent_flags = intent.getFlags();
	// Intent flags could only filter background receivers, we have to deal with services by ourselves.
	return mCondom.proceed(OutboundType.QUERY_SERVICES, intent, null, new CondomCore.WrappedValueProcedure<ResolveInfo>() { @Override public ResolveInfo proceed() {
		if (! mCondom.mExcludeBackgroundServices && mCondom.mOutboundJudge == null)
			return CondomPackageManager.super.resolveService(intent, flags);	// Shortcut for pass-through

		final List<ResolveInfo> candidates = CondomPackageManager.super.queryIntentServices(intent, flags);
		final Intent original_intent = intent.setFlags(original_intent_flags);	// Restore the intent flags early before getFirstMatch().
		return mCondom.filterCandidates(OutboundType.QUERY_SERVICES, original_intent, candidates, TAG, false);
	}});
}
 
Example 5
Project: container   File: IntentResolver.java   View Source Code Vote up 6 votes
public List<R> queryIntentFromList(Intent intent, String resolvedType, boolean defaultOnly,
		ArrayList<F[]> listCut) {
	ArrayList<R> resultList = new ArrayList<R>();

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

	FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
	final String scheme = intent.getScheme();
	int N = listCut.size();
	for (int i = 0; i < N; ++i) {
		buildResolveList(intent, categories, debug, defaultOnly, resolvedType, scheme, listCut.get(i), resultList);
	}
	sortResults(resultList);
	return resultList;
}
 
Example 6
Project: LaunchTime   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);


    if (System.currentTimeMillis() - mPauseTime < 1000  && Intent.ACTION_MAIN.equals(intent.getAction())) {

        final boolean alreadyOnHome =
                ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
                        != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
        Log.d("LaunchTime", " new intent " + alreadyOnHome);
        if (alreadyOnHome && !mChildLock) {

            // If we are on home screen, reset most things and go to top category.
            mCategoriesScroller.postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        mSearchBox.setSearchText("");
                        mCategoriesScroller.smoothScrollTo(0, 0);
                        showButtonBar(false, true);
                        mIconSheetScroller.smoothScrollTo(0, 0);
                        switchCategory(getTopCategory());
                        mQuickRow.scrollToStart();
                        mIconSheetScroller.smoothScrollTo(0, 0);
                        mCategoriesScroller.smoothScrollTo(0, 0);
                    } catch (Exception e) {
                        Log.e(TAG, e.getMessage(), e);
                    }

                }
            }, 200);
        }

    }
}
 
Example 7
Project: Android-BitherCompress-master   File: MainActivity.java   View Source Code Vote up 6 votes
@SuppressWarnings("ResourceType")
@TargetApi(Build.VERSION_CODES.KITKAT)
public static Uri ensureUriPermission(Context context, Intent intent) {
    Uri uri = intent.getData();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        final int takeFlags = intent.getFlags() & Intent.FLAG_GRANT_READ_URI_PERMISSION;
        context.getContentResolver().takePersistableUriPermission(uri, takeFlags);
    }
    return uri;
}
 
Example 8
Project: chromium-for-android-56-debug-video   File: ChromeLauncherActivity.java   View Source Code Vote up 6 votes
/**
 * Creates an Intent that can be used to launch a {@link CustomTabActivity}.
 */
public static Intent createCustomTabActivityIntent(
        Context context, Intent intent, boolean addHerbExtras) {
    // Use the copy constructor to carry over the myriad of extras.
    Uri uri = Uri.parse(IntentHandler.getUrlFromIntent(intent));

    Intent newIntent = new Intent(intent);
    newIntent.setAction(Intent.ACTION_VIEW);
    newIntent.setClassName(context, CustomTabActivity.class.getName());
    newIntent.setData(uri);

    // If a CCT intent triggers First Run, then NEW_TASK will be automatically applied.  As
    // part of that, it will inherit the EXCLUDE_FROM_RECENTS bit from ChromeLauncherActivity,
    // so explicitly remove it to ensure the CCT does not get lost in recents.
    if ((newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0
            || (newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0) {
        newIntent.setFlags(
                newIntent.getFlags() & ~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    }

    if (addHerbExtras) {
        // TODO(tedchoc|mariakhomenko): Specifically not marking the intent is from Chrome via
        //                              IntentHandler.addTrustedIntentExtras as it breaks the
        //                              redirect logic for triggering instant apps.  See if
        //                              this is better addressed in TabRedirectHandler long
        //                              term.
        newIntent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME, true);
    } else {
        IntentUtils.safeRemoveExtra(
                intent, CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME);
    }
    if (addHerbExtras) updateHerbIntent(context, newIntent);

    return newIntent;
}
 
Example 9
Project: Android-App-Linking   File: Flags.java   View Source Code Vote up 6 votes
static HashSet<String> extract(@NonNull Intent intent) {
    final int flags = intent.getFlags();
    HashSet<String> flagsStrings = new HashSet<>();
    for (int i = 0; i < FLAGS.size(); i++) {
        int key = FLAGS.keyAt(i);
        String value = FLAGS.valueAt(i);
        if ((flags & key) != 0) {
            flagsStrings.add(value);
        }
    }
    return flagsStrings;
}
 
Example 10
Project: KTools   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if ((Intent.FLAG_ACTIVITY_CLEAR_TOP & intent.getFlags()) != 0 ){
        finish();
    }
}
 
Example 11
Project: container   File: BroadcastSystem.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    if (mApp.isBooting()) {
        return;
    }
    if ((intent.getFlags() & FLAG_RECEIVER_REGISTERED_ONLY) != 0 || isInitialStickyBroadcast()) {
        return;
    }
    PendingResult result = goAsync();
    synchronized (mAMS) {
        if (!mAMS.handleStaticBroadcast(appId, info, intent, new PendingResultData(result))) {
            result.finish();
        }
    }
}
 
Example 12
Project: condom   File: CondomPackageManager.java   View Source Code Vote up 6 votes
@Override public List<ResolveInfo> queryIntentServices(final Intent intent, final int flags) {
	final int original_intent_flags = intent.getFlags();
	return mCondom.proceedQuery(OutboundType.QUERY_SERVICES, intent, new CondomCore.WrappedValueProcedure<List<ResolveInfo>>() {
		@Override public List<ResolveInfo> proceed() {
			final List<ResolveInfo> result = CondomPackageManager.super.queryIntentServices(intent, flags);
			mCondom.filterCandidates(OutboundType.QUERY_SERVICES, intent.setFlags(original_intent_flags), result, TAG, true);
			return result;
		}
	}, CondomCore.SERVICE_PACKAGE_GETTER);
}
 
Example 13
Project: condom   File: CondomPackageManager.java   View Source Code Vote up 5 votes
@Override public ResolveInfo resolveService(final Intent intent, final int flags) {
	final int original_intent_flags = intent.getFlags();
	// Intent flags could only filter background receivers, we have to deal with services by ourselves.
	return mCondom.proceed(OutboundType.QUERY_SERVICES, intent, null, new CondomCore.WrappedValueProcedure<ResolveInfo>() {
		@Override public ResolveInfo proceed() {
			if (! mCondom.mExcludeBackgroundServices && mCondom.mOutboundJudge == null)
				return CondomPackageManager.super.resolveService(intent, flags);    // Shortcut for pass-through

			final List<ResolveInfo> candidates = CondomPackageManager.super.queryIntentServices(intent, flags);
			final Intent original_intent = intent.setFlags(original_intent_flags);    // Restore the intent flags early before getFirstMatch().
			return mCondom.filterCandidates(OutboundType.QUERY_SERVICES, original_intent, candidates, TAG, false);
		}
	});
}
 
Example 14
Project: VirtualHook   File: BroadcastSystem.java   View Source Code Vote up 5 votes
@Override
public void onReceive(Context context, Intent intent) {
    if (mApp.isBooting()) {
        return;
    }
    if ((intent.getFlags() & FLAG_RECEIVER_REGISTERED_ONLY) != 0 || isInitialStickyBroadcast()) {
        return;
    }
    PendingResult result = goAsync();
    if (!mAMS.handleStaticBroadcast(appId, info, intent, new PendingResultData(result))) {
        result.finish();
    }
}
 
Example 15
Project: MiPushFramework   File: CondomContext.java   View Source Code Vote up 5 votes
@Override public List<ResolveInfo> queryIntentServices(final Intent intent, final int flags) {
	final int original_intent_flags = intent.getFlags();
	return mCondom.proceedQuery(OutboundType.QUERY_SERVICES, intent, new CondomCore.WrappedValueProcedure<List<ResolveInfo>>() { @Override public List<ResolveInfo> proceed() {
		final List<ResolveInfo> result = CondomPackageManager.super.queryIntentServices(intent, flags);
		mCondom.filterCandidates(OutboundType.QUERY_SERVICES, intent.setFlags(original_intent_flags), result, TAG, true);
		return result;
	}});
}
 
Example 16
Project: atlas   File: IntentResolver.java   View Source Code Vote up 5 votes
public List<R> queryIntent(Intent intent, String resolvedType, boolean defaultOnly) {
    String scheme = intent.getScheme();

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

    final boolean debug = localLOGV ||
            ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
    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);
                    secondTypeCut = mWildTypeToFilter.get(baseType);
                } else {
                    // We can match anything with our base type.
                    firstTypeCut = mBaseTypeToFilter.get(baseType);
                    secondTypeCut = mWildTypeToFilter.get(baseType);
                }
                // Any */* types always apply, but we only need to do this
                // if the intent type was not already */*.
                thirdTypeCut = mWildTypeToFilter.get("*");
            } 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 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 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());
    }

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

    return finalList;
}
 
Example 17
Project: prevent   File: PreventRunningUtils.java   View Source Code Vote up 5 votes
public static boolean isExcludingStopped(Intent intent) {
    String action = intent.getAction();
    return ((intent.getFlags() & (Intent.FLAG_EXCLUDE_STOPPED_PACKAGES | Intent.FLAG_INCLUDE_STOPPED_PACKAGES)) == Intent.FLAG_EXCLUDE_STOPPED_PACKAGES)
            && action != null && mPreventRunning.isExcludingStopped(action);
}
 
Example 18
Project: condom   File: CondomContextBlockingTest.java   View Source Code Vote up 5 votes
@CallSuper void check(final Intent intent) {
	assertBaseNotCalled();
	mBaseCalled = true;
	mIntentFlags = intent.getFlags();
}
 
Example 19
Project: container   File: ActivityStack.java   View Source Code Vote up 5 votes
private static boolean containFlags(Intent intent, int flags) {
    return (intent.getFlags() & flags) != 0;
}
 
Example 20
Project: photo-editor-android   File: MediaActivity.java   View Source Code Vote up 5 votes
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (resultCode) {
        case RESULT_CANCELED:
            break;
        case RESULT_OK:
            if (requestCode == GALLERY_INTENT_CALLED || requestCode == CAMERA_CODE
                    || requestCode == GALLERY_KITKAT_INTENT_CALLED) {
                if (requestCode == GALLERY_INTENT_CALLED) {
                    selectedImageUri = data.getData();
                    selectedImagePath = getPath(selectedImageUri);
                } else if (requestCode == GALLERY_KITKAT_INTENT_CALLED) {
                    selectedImageUri = data.getData();
                    final int takeFlags = data.getFlags()
                            & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                    // Check for the freshest data.
                    if (selectedImageUri != null) {
                        getContentResolver().takePersistableUriPermission(
                                selectedImageUri, takeFlags);
                        selectedImagePath = getPath(selectedImageUri);
                    }
                } else {
                    selectedImagePath = selectedOutputPath;
                }

                if (UtilFunctions.stringIsNotEmpty(selectedImagePath)) {
                    // decode image size
                    BitmapFactory.Options o = new BitmapFactory.Options();
                    o.inJustDecodeBounds = true;
                    BitmapFactory.decodeFile(selectedImagePath, o);
                    // Find the correct scale value. It should be the power of
                    // 2.
                    int width_tmp = o.outWidth, height_tmp = o.outHeight;
                    Log.d("MediaActivity", "MediaActivity : image size : "
                            + width_tmp + " ; " + height_tmp);
                    final int MAX_SIZE = getResources().getDimensionPixelSize(
                            R.dimen.image_loader_post_width);
                    int scale = 1;
                    // while (true) {
                    // if (width_tmp / 2 < MAX_SIZE
                    // || height_tmp / 2 < MAX_SIZE)
                    // break;
                    // width_tmp /= 2;
                    // height_tmp /= 2;
                    // scale *= 2;
                    // }
                    if (height_tmp > MAX_SIZE || width_tmp > MAX_SIZE) {
                        if (width_tmp > height_tmp) {
                            scale = Math.round((float) height_tmp
                                    / (float) MAX_SIZE);
                        } else {
                            scale = Math.round((float) width_tmp
                                    / (float) MAX_SIZE);
                        }
                    }
                    Log.d("MediaActivity", "MediaActivity : scaling image by factor : " + scale);
                    BitmapFactory.Options options = new BitmapFactory.Options();
                    options.inSampleSize = scale;
                    bitmap = BitmapFactory.decodeFile(selectedImagePath, options);
                    _taken = true;
                    onPhotoTaken();
                    System.gc();
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}