Java Code Examples for android.content.IntentFilter#addDataScheme()

The following examples show how to use android.content.IntentFilter#addDataScheme() . These examples are extracted from open source projects. 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
@Override public void onCreate() {
	super.onCreate();
	final Context context = SDK_INT >= N ? createDeviceProtectedStorageContext() : this;
	//noinspection deprecation
	mPreferences = context.getSharedPreferences(PREFERENCES_NAME, MODE_MULTI_PROCESS);
	migrateFromLegacyPreferences();		// TODO: Remove this IO-blocking migration code (created in Aug, 2019).
	mPrefKeyWear = getString(R.string.pref_wear);

	mMessagingBuilder = new MessagingBuilder(this, new MessagingBuilder.Controller() {
		@Override public void recastNotification(final String key, final Bundle addition) {
			WeChatDecorator.this.recastNotification(key, addition);
		}
		@Override public Conversation getConversation(final int id) {
			return mConversationManager.getConversation(id);
		}
	});	// Must be called after loadPreferences().
	final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_REMOVED); filter.addDataScheme("package");
	registerReceiver(mPackageEventReceiver, filter);
	registerReceiver(mSettingsChangedReceiver, new IntentFilter(ACTION_SETTINGS_CHANGED));
}
 
Example 2
Source Project: letv   File: TopRecommendFragment.java    License: Apache License 2.0 6 votes vote down vote up
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    selectedType = 0;
    this.exchid = "2";
    this.isFirst = true;
    this.currentPage = 1;
    this.currentPage2 = 1;
    this.currentPage3 = 1;
    findView();
    this.inBootReciever = new BootReciever(this);
    IntentFilter filter = new IntentFilter();
    filter.addAction("android.intent.action.PACKAGE_ADDED");
    filter.addAction("android.intent.action.PACKAGE_REMOVED");
    filter.addDataScheme("package");
    getActivity().registerReceiver(this.inBootReciever, filter);
}
 
Example 3
Source Project: styT   File: S_MVP.java    License: Apache License 2.0 6 votes vote down vote up
public void onCreate() {
    //  myLog.l(Log.DEBUG, "SwiFTP server created");
    // Set the application-wide context global, if not already set
    Context myContext = Globals.getContext();
    if (myContext == null) {
        myContext = getApplicationContext();
        if (myContext != null) {
            Globals.setContext(myContext);
        }
    }

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    intentFilter.addDataScheme("file");
    registerReceiver(mReceiver, intentFilter);
    return;
}
 
Example 4
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    intentFilter.addDataScheme("package");

    registerReceiver(_packageUpdateReceiver, intentFilter);

    mNavigationDrawerFragment = (NavigationDrawerFragment)
            getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
    mTitle = getTitle();

    // Set up the drawer.
    mNavigationDrawerFragment.setUp(
            R.id.navigation_drawer,
            (DrawerLayout) findViewById(R.id.drawer_layout));

    restoreActionBar();

    DatabaseUtils.fillSuspectedApps(this);
}
 
Example 5
@Override
public void onCreate() {
    super.onCreate();

    // TODO Detect -somehow- new adopted storage on running time

    // Create and configure a broadcast receiver.
    br = new MyBroadcastReceiver();

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    filter.addAction(Intent.ACTION_MEDIA_REMOVED);
    filter.addDataScheme("file");
    this.registerReceiver(br, filter);

    // Detect storage devices on this android terminal
    loadStorage();

    // Handler for interface updating
    this.handler = new Handler();
    this.handler.post(refresh);

    // Control messages
    Toaster.toast("DISK Service & Publisher RUNNING");
    Log.i("LOG", "ONCREATE FINISHED!");
}
 
Example 6
@Override
public void onCreate() {
    super.onCreate();
    log.d("onCreate()");

    IntentFilter intentFilter = new IntentFilter(ACTION_STOP_RECORDING);
    intentFilter.addDataScheme(URI_SCHEME);

    registerReceiver(receiver, intentFilter);

    handler = new Handler(Looper.getMainLooper());
}
 
Example 7
public IntentFilter buildFilter() {
    Log.i(TAG, "buildFilter()");
    IntentFilter filter = new IntentFilter(Response.RESPONSE);
    filter.addDataScheme(Subjects.CONTENT_URI.getScheme());
    try {

        filter.addDataType(Subjects.CONTENT_TYPE);
        filter.addDataType(Subjects.CONTENT_ITEM_TYPE);
    } catch (IntentFilter.MalformedMimeTypeException e) {

    }
    return filter;
}
 
Example 8
public PackageIntentReceiver(MainLoader loader) {
    mLoader = loader;
    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    mLoader.getContext().registerReceiver(this, filter);
    // Register for events related to sdcard installation.
    IntentFilter sdFilter = new IntentFilter();
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    filter.addAction(Intent.ACTION_LOCALE_CHANGED);
    mLoader.getContext().registerReceiver(this, sdFilter);
}
 
Example 9
Source Project: androidtestdebug   File: SampleTest.java    License: MIT License 5 votes vote down vote up
public void test点击链接() {
	final Instrumentation inst = getInstrumentation();
	IntentFilter intentFilter = new IntentFilter(Intent.ACTION_VIEW);
	intentFilter.addDataScheme("http");
	intentFilter.addCategory(Intent.CATEGORY_BROWSABLE);
	View link = this.getActivity().findViewById(R.id.link);
	ActivityMonitor monitor = inst.addMonitor(
			intentFilter, null, false);
	assertEquals(0, monitor.getHits());
	TouchUtils.clickView(this, link);
	monitor.waitForActivityWithTimeout(5000);
	assertEquals(1, monitor.getHits());
	inst.removeMonitor(monitor);
}
 
Example 10
@Override
public void onCreate() {
    super.onCreate();
    log.d("onCreate()");

    IntentFilter intentFilter = new IntentFilter(ACTION_STOP_RECORDING);
    intentFilter.addDataScheme(URI_SCHEME);

    registerReceiver(receiver, intentFilter);

    handler = new Handler(Looper.getMainLooper());
}
 
Example 11
Source Project: android-tv-launcher   File: AppUninstall.java    License: MIT License 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    Log.i(TAG, "============onStart========");
    receiver = new Receiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction("android.intent.action.PACKAGE_ADDED");
    filter.addAction("android.intent.action.PACKAGE_REMOVED");
    filter.addDataScheme("package");
    this.registerReceiver(receiver, filter);
}
 
Example 12
ContentService(Context context, boolean factoryTest) {
    mContext = context;
    mFactoryTest = factoryTest;

    // Let the package manager query for the sync adapters for a given authority
    // as we grant default permissions to sync adapters for specific authorities.
    PackageManagerInternal packageManagerInternal = LocalServices.getService(
            PackageManagerInternal.class);
    packageManagerInternal.setSyncAdapterPackagesprovider(
            new PackageManagerInternal.SyncAdapterPackagesProvider() {
                @Override
                public String[] getPackages(String authority, int userId) {
                    return getSyncAdapterPackagesForAuthorityAsUser(authority, userId);
                }
            });

    final IntentFilter packageFilter = new IntentFilter();
    packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED);
    packageFilter.addDataScheme("package");
    mContext.registerReceiverAsUser(mCacheReceiver, UserHandle.ALL,
            packageFilter, null, null);

    final IntentFilter localeFilter = new IntentFilter();
    localeFilter.addAction(Intent.ACTION_LOCALE_CHANGED);
    mContext.registerReceiverAsUser(mCacheReceiver, UserHandle.ALL,
            localeFilter, null, null);
}
 
Example 13
@Override
public void startListening() {
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    intentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    intentFilter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED);
    intentFilter.addDataScheme("package");
    EventRegistry.context.registerReceiver(this, intentFilter);
}
 
Example 14
public ApplicationsReceiver(AppsLoader loader) {
    mLoader = loader;
    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    mLoader.getContext().registerReceiver(this, filter);
    IntentFilter sdFilter = new IntentFilter();
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    mLoader.getContext().registerReceiver(this, sdFilter);
}
 
Example 15
Source Project: FireFiles   File: DocumentsApplication.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if(!BuildConfig.DEBUG) {
        AnalyticsManager.intialize(getApplicationContext());
    }
    sInstance = this;
    final ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    final int memoryClassBytes = am.getMemoryClass() * 1024 * 1024;

    mRoots = new RootsCache(this);
    mRoots.updateAsync();

    mSAFManager = new SAFManager(this);

    mThumbnails = new ThumbnailCache(memoryClassBytes / 4);

    final IntentFilter packageFilter = new IntentFilter();
    packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED);
    packageFilter.addDataScheme("package");
    registerReceiver(mCacheReceiver, packageFilter);

    final IntentFilter localeFilter = new IntentFilter();
    localeFilter.addAction(Intent.ACTION_LOCALE_CHANGED);
    registerReceiver(mCacheReceiver, localeFilter);

    isTelevision = Utils.isTelevision(this);
}
 
Example 16
Source Project: Camera2   File: VideoModule.java    License: Apache License 2.0 5 votes vote down vote up
private void installIntentFilter()
{
    // install an intent filter to receive SD card related events.
    IntentFilter intentFilter =
            new IntentFilter(Intent.ACTION_MEDIA_EJECT);
    intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
    intentFilter.addDataScheme("file");
    mReceiver = new MyBroadcastReceiver();
    mActivity.registerReceiver(mReceiver, intentFilter);
}
 
Example 17
Source Project: V.FlyoutTest   File: LoaderCustomSupport.java    License: MIT License 5 votes vote down vote up
public PackageIntentReceiver(AppListLoader loader) {
    mLoader = loader;
    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    mLoader.getContext().registerReceiver(this, filter);
    // Register for events related to sdcard installation.
    IntentFilter sdFilter = new IntentFilter();
    sdFilter.addAction(IntentCompat.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    sdFilter.addAction(IntentCompat.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    mLoader.getContext().registerReceiver(this, sdFilter);
}
 
Example 18
Source Project: talkback   File: FailoverTextToSpeech.java    License: Apache License 2.0 4 votes vote down vote up
public MediaMountStateMonitor() {
  mMediaIntentFilter = new IntentFilter();
  mMediaIntentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
  mMediaIntentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
  mMediaIntentFilter.addDataScheme("file");
}
 
Example 19
public IntentFilter toIntentFilter(int type)
{
	if (1 == type)
	{
		return toIntentFilter();
	}
	
	IntentFilter filter = toIntentFilter();
	
	try
	{
		//for mimetype
		if (type >= 1)
		{
			if (! StringUtil.isEmpty(dataAndType.getType()))
			{
				if (! StringUtil.isEmpty(dataAndType.getSubtype()))
				{
					filter.addDataType(dataAndType.getType() + "/" + dataAndType.getSubtype());
					filterType = 2;
				}
				else
				{
					filter.addDataType(dataAndType.getType());
					filterType = 2;
				}
			}
		}
		
		//for data
		if (type >= 2)
		{
			if (! StringUtil.isEmpty(dataAndType.getHost()))
			{
				if (! StringUtil.isEmpty(dataAndType.getPort()))
				{
					filter.addDataAuthority(dataAndType.getHost(), dataAndType.getPort());
				}
				else
				{
					filter.addDataAuthority(dataAndType.getHost(), null);
				}
				
				
				filterType = 3;
			}
			
			if (! StringUtil.isEmpty(dataAndType.getPath()))
			{
				filter.addDataPath(dataAndType.getPath(), PatternMatcher.PATTERN_LITERAL);
				
				filterType = 3;
			}
			
			if (! StringUtil.isEmpty(dataAndType.getScheme()))
			{
				filter.addDataScheme(dataAndType.getScheme());
				
				filterType = 3;
			}
		}
	}
	catch (Exception ex)
	{
		ex.printStackTrace();
	}
	
	return filter;
}
 
Example 20
@Override
public void onCreate() {
    notificationManager = (NotificationManager) this.getSystemService(NOTIFICATION_SERVICE);

    Log.i(LOG_TAG, "VPN Create version=" + Util.getSelfVersionName(this) + "/" + Util.getSelfVersionCode(this));

    Util.canFilterAsynchronous(this);

    if (jni_context != 0) {
        Log.w(LOG_TAG, "VPN Create with context=" + jni_context);
        jni_stop(jni_context);
        synchronized (jni_lock) {
            jni_done(jni_context);
            jni_context = 0;
        }
    }

    // Native init
    jni_context = jni_init(Build.VERSION.SDK_INT);
    Log.i(LOG_TAG, "VPN Created context=" + jni_context);

    super.onCreate();

    HandlerThread commandThread = new HandlerThread(getString(R.string.app_name) + " command", Process.THREAD_PRIORITY_FOREGROUND);
    commandThread.start();

    commandLooper = commandThread.getLooper();

    commandHandler = ServiceVPNHandler.getInstance(commandLooper, this);

    // Listen for idle mode state changes
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        IntentFilter ifIdle = new IntentFilter();
        ifIdle.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
        registerReceiver(idleStateReceiver, ifIdle);
        registeredIdleState = true;
    }

    // Listen for added/removed applications
    IntentFilter ifPackage = new IntentFilter();
    ifPackage.addAction(Intent.ACTION_PACKAGE_ADDED);
    ifPackage.addAction(Intent.ACTION_PACKAGE_REMOVED);
    ifPackage.addDataScheme("package");
    registerReceiver(packageChangedReceiver, ifPackage);
    registeredPackageChanged = true;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        try {
            listenNetworkChanges();
        } catch (Throwable ex) {
            Log.w(LOG_TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
            listenConnectivityChanges();
        }
    } else {
        listenConnectivityChanges();
    }
}