android.content.IntentFilter Java Examples

The following examples show how to use android.content.IntentFilter. 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: IntentResolver.java    From container with GNU General Public License v3.0 6 votes vote down vote up
private ArrayList<F> collectFilters(F[] array, IntentFilter matching) {
	ArrayList<F> res = null;
	if (array != null) {
		for (int i = 0; i < array.length; i++) {
			F cur = array[i];
			if (cur == null) {
				break;
			}
			if (filterEquals(cur, matching)) {
				if (res == null) {
					res = new ArrayList<>();
				}
				res.add(cur);
			}
		}
	}
	return res;
}
 
Example #2
Source File: NotificationActivity.java    From LNMOnlineAndroidSample with Apache License 2.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    // register GCM registration complete receiver.
    LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
            new IntentFilter(REGISTRATION_COMPLETE));

    // register new push message receiver.
    // by doing this, the activity will be notified each time a new message arrives
    LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
            new IntentFilter(PUSH_NOTIFICATION));

    // clear the notification area when the app is opened.
    NotificationUtils.clearNotifications(getApplicationContext());
}
 
Example #3
Source File: ZenNotificationActivity.java    From zen4android with MIT License 6 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	try {
		
		IntentFilter filter = new IntentFilter();
		filter.addAction(ZenNotificationModel.ZEN_NEW_NOTIFICATION);
		filter.addAction(ZenNotificationModel.ZEN_NOTIFICATION_EMPTY);
		filter.addAction(ZenNotificationModel.ZEN_LOAD_NOTIFICATION_FAILED);
		registerReceiver(mBroadcastReceiver, filter);
		
		if (ZenUtils.getToken() != null) {
			// loged in
			mLoadingView.show();
			model.load();
		}
		refresh();
		
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #4
Source File: UiLifecycleHelper.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * To be called from an Activity or Fragment's onResume method.
 */
public void onResume() {
    Session session = Session.getActiveSession();
    if (session != null) {
        if (callback != null) {
            session.addCallback(callback);
        }
        if (SessionState.CREATED_TOKEN_LOADED.equals(session.getState())) {
            session.openForRead(null);
        }
    }

    // add the broadcast receiver
    IntentFilter filter = new IntentFilter();
    filter.addAction(Session.ACTION_ACTIVE_SESSION_SET);
    filter.addAction(Session.ACTION_ACTIVE_SESSION_UNSET);

    // Add a broadcast receiver to listen to when the active Session
    // is set or unset, and add/remove our callback as appropriate
    broadcastManager.registerReceiver(receiver, filter);
}
 
Example #5
Source File: MentionsCommentTimeLineFragment.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
@Override
    public void onResume() {
        super.onResume();
        setListViewPositionFromPositionsCache();
        LocalBroadcastManager.getInstance(getActivity()).registerReceiver(newBroadcastReceiver,
                new IntentFilter(AppEventAction.NEW_MSG_BROADCAST));
        // setActionBarTabCount(newMsgTipBar.getValues().size());
        getNewMsgTipBar().setOnChangeListener(new TopTipsView.OnChangeListener() {
            @Override
            public void onChange(int count) {
//                ((MainTimeLineActivity) getActivity()).setMentionsCommentCount(count);
                // setActionBarTabCount(count);
            }
        });
        checkUnreadInfo();
    }
 
Example #6
Source File: ActivityHook.java    From AppTroy with Apache License 2.0 6 votes vote down vote up
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
    Log.d("cc", "before, register receiver");
    if (NEED_DEBUG) {
        Activity activity = (Activity) param.thisObject;
        Log.d(LOG_TAG, activity.toString());
    }
    if (!ModuleContext.HAS_REGISTER_LISENER) {
        Activity app = (Activity) param.thisObject;
        IntentFilter filter = new IntentFilter(CommandBroadcastReceiver.INTENT_ACTION);
        app.registerReceiver(new CommandBroadcastReceiver(), filter);
        ModuleContext.HAS_REGISTER_LISENER = true;
        ModuleContext.getInstance().setFirstApplication(app.getApplication());
        Log.d("cc", "register over");
    }
}
 
Example #7
Source File: BatteryMessageProvider.java    From PresencePublisher with MIT License 6 votes vote down vote up
@Override
protected List<String> getMessageContents() {
    if (!getSharedPreferences().getBoolean(SEND_BATTERY_MESSAGE, false)) {
        HyperLog.d(TAG, "Battery messages disabled, not generating any messages");
        return Collections.emptyList();
    }

    HyperLog.i(TAG, "Scheduling battery message");
    IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    Intent batteryStatus = getApplicationContext().registerReceiver(null, filter);

    if (batteryStatus == null) {
        HyperLog.w(TAG, "No battery status received, unable to generate message");
        return Collections.emptyList();
    }

    int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
    int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

    int batteryPct = (int) (level / (0.01f * scale));

    return Collections.singletonList(Integer.toString(batteryPct));
}
 
Example #8
Source File: FolderPickerActivity.java    From Cirrus_depricated with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    Log_OC.e(TAG, "onResume() start");

    // refresh list of files
    refreshListOfFilesFragment();

    // Listen for sync messages
    IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START);
    syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_END);
    syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED);
    syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
    syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
    mSyncBroadcastReceiver = new SyncBroadcastReceiver();
    registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);

    Log_OC.d(TAG, "onResume() end");
}
 
Example #9
Source File: TriggerLoop.java    From Trigger with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    jobSet = new ConcurrentHashMap<>();
    receivers = new ConcurrentHashMap<>();
    jobHappens = new ConcurrentHashMap<>();
    binder = new TriggerBinder();
    executor = Executors.newFixedThreadPool(THREAD_POOL_SIZE, new TriggerWorkerFactory());
    mainHandler = new Handler(Looper.getMainLooper());
    alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    shortDeadlineHandler = new Handler();
    deadlineCheck = new DeadlineCheck();
    sDeviceStatus = DeviceStatus.get(this);
    registerReceiver(deadlineCheck, new IntentFilter(DEADLINE_BROADCAST));
    PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
    int granted = checkCallingOrSelfPermission("android.permission.WAKE_LOCK");
    if (granted == PackageManager.PERMISSION_GRANTED) {
        wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
    } else {
        wakeLock = null;
    }
    handlerThread = new HandlerThread("Trigger-HandlerThread");
    handlerThread.start();
    checker = new CheckHandler(handlerThread.getLooper());
    mayRecoverJobsFromFile();
}
 
Example #10
Source File: FreezeService.java    From Shelter with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    // Save usage statistics right now!
    // We need to use the statics at this moment
    // for "skipping foreground apps"
    // No app is foreground after the screen is locked.
    mScreenLockTime = new Date().getTime();
    if (SettingsManager.getInstance().getSkipForegroundEnabled() &&
            Utility.checkUsageStatsPermission(FreezeService.this)) {
        UsageStatsManager usm = getSystemService(UsageStatsManager.class);
        mUsageStats = usm.queryAndAggregateUsageStats(mScreenLockTime - APP_INACTIVE_TIMEOUT, mScreenLockTime);
    }

    // Delay the work so that it can be canceled if the screen
    // gets unlocked before the delay passes
    mHandler.postDelayed(mFreezeWork,
            ((long) SettingsManager.getInstance().getAutoFreezeDelay()) * 1000);
    registerReceiver(mUnlockReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
}
 
Example #11
Source File: CustomTabsHelper.java    From android-browser-helper with Apache License 2.0 6 votes vote down vote up
/**
 * Used to check whether there is a specialized handler for a given intent.
 * @param intent The intent to check with.
 * @return Whether there is a specialized handler for the given intent.
 */
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
    try {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> handlers = pm.queryIntentActivities(
                intent,
                PackageManager.GET_RESOLVED_FILTER);
        if (handlers.size() == 0) {
            return false;
        }
        for (ResolveInfo resolveInfo : handlers) {
            IntentFilter filter = resolveInfo.filter;
            if (filter == null) continue;
            if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue;
            if (resolveInfo.activityInfo == null) continue;
            return true;
        }
    } catch (RuntimeException e) {
        Log.e(TAG, "Runtime exception while getting specialized handlers");
    }
    return false;
}
 
Example #12
Source File: TTIntent.java    From TwistyTimer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Registers a broadcast receiver. The receiver will only be notified of intents that require
 * the category given and only for the actions that are supported for that category. If the
 * receiver is used by a fragment, create an instance of {@link TTFragmentBroadcastReceiver}
 * and register it with the {@link #registerReceiver(TTFragmentBroadcastReceiver)} method
 * instead, as it will be easier to maintain.
 *
 * @param receiver
 *     The broadcast receiver to be registered.
 * @param category
 *     The category for the actions to be received. Must not be {@code null} and must be a
 *     supported category.
 *
 * @throws IllegalArgumentException
 *     If the category is {@code null}, or is not one of the supported categories.
 */
public static void registerReceiver(BroadcastReceiver receiver, String category) {
    final String[] actions = ACTIONS_SUPPORTED_BY_CATEGORY.get(category);

    if (category == null || actions.length == 0) {
        throw new IllegalArgumentException("Category is not supported: " + category);
    }

    final IntentFilter filter = new IntentFilter();

    filter.addCategory(category);

    for (String action : actions) {
        // IntentFilter will only match Intents with one of these actions.
        filter.addAction(action);
    }

    LocalBroadcastManager.getInstance(TwistyTimer.getAppContext())
            .registerReceiver(receiver, filter);
}
 
Example #13
Source File: ServerConnection.java    From habpanelviewer with GNU General Public License v3.0 6 votes vote down vote up
public ServerConnection(Context context) {
    mCertListener = () -> {
        Log.d(TAG, "cert added, reconnecting to server...");

        if (mSseConnection.getStatus() == SseConnection.Status.CERTIFICATE_ERROR) {
            mSseConnection.connect();
        }
    };

    mSseConnection.addListener(new SseConnectionListener());
    mSseConnection.addItemValueListener(new SseStateUpdateListener());

    CertificateManager.getInstance().addCertListener(mCertListener);
    CredentialManager.getInstance().addCredentialsListener(mSseConnection);

    IntentFilter f = new IntentFilter();
    f.addAction(Constants.INTENT_ACTION_SET_WITH_TIMEOUT);

    LocalBroadcastManager.getInstance(context).registerReceiver(mReceiver, f);
}
 
Example #14
Source File: CustomTabsHelper.java    From custom-tabs-client with Apache License 2.0 6 votes vote down vote up
/**
 * Used to check whether there is a specialized handler for a given intent.
 * @param intent The intent to check with.
 * @return Whether there is a specialized handler for the given intent.
 */
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
    try {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> handlers = pm.queryIntentActivities(
                intent,
                PackageManager.GET_RESOLVED_FILTER);
        if (handlers == null || handlers.size() == 0) {
            return false;
        }
        for (ResolveInfo resolveInfo : handlers) {
            IntentFilter filter = resolveInfo.filter;
            if (filter == null) continue;
            if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue;
            if (resolveInfo.activityInfo == null) continue;
            return true;
        }
    } catch (RuntimeException e) {
        Log.e(TAG, "Runtime exception while getting specialized handlers");
    }
    return false;
}
 
Example #15
Source File: Magnet.java    From Magnet with MIT License 5 votes vote down vote up
/**
 * Show the Magnet i.e. add it to the Window
 */
public void show() {
  addToWindow();
  iconView.setOnClickListener(this);
  initializeMotionPhysics();
  if (initialX != -1 || initialY != -1) {
    setPosition(initialX, initialY);
  } else {
    goToWall();
  }
  xSpring.addListener(this);
  ySpring.addListener(this);
  context.registerReceiver(orientationChangeReceiver,
      new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
}
 
Example #16
Source File: ColdActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    BitherApplication.coldActivity = this;
    setContentView(R.layout.activity_cold);
    initView();
    mPager.postDelayed(new Runnable() {

        @Override
        public void run() {
            initClick();
            mPager.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Fragment f = getActiveFragment();
                    if (f instanceof Selectable) {
                        ((Selectable) f).onSelected();
                    }

                    BackupUtil.backupColdKey(true);
                }
            }, 100);

        }
    }, 500);
    DialogFirstRunWarning.show(this);
    registerReceiver(addressIsLoadedReceiver, new IntentFilter(NotificationAndroidImpl
            .ACTION_ADDRESS_LOAD_COMPLETE_STATE));
}
 
Example #17
Source File: ChangeCharActivity.java    From bleTester with Apache License 2.0 5 votes vote down vote up
private IntentFilter makeIntentFilter() {
	// TODO Auto-generated method stub
	IntentFilter intentFilter = new IntentFilter();
	intentFilter.addAction(BleService.ACTION_CHAR_READED);
	intentFilter.addAction(BleService.ACTION_GATT_CONNECTED);
	intentFilter.addAction(BleService.ACTION_GATT_DISCONNECTED);
	intentFilter.addAction(BleService.ACTION_GATT_SERVICES_DISCOVERED);
	intentFilter.addAction(BleService.ACTION_DATA_AVAILABLE);
	intentFilter.addAction(BleService.BATTERY_LEVEL_AVAILABLE);
	intentFilter.addAction(BleService.ACTION_GATT_RSSI);
	return intentFilter;
}
 
Example #18
Source File: BleScanActivity.java    From BleLib with Apache License 2.0 5 votes vote down vote up
private static IntentFilter makeIntentFilter() {
    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(BleService.ACTION_BLUETOOTH_DEVICE);
    intentFilter.addAction(BleService.ACTION_GATT_CONNECTED);
    intentFilter.addAction(BleService.ACTION_GATT_DISCONNECTED);
    intentFilter.addAction(BleService.ACTION_SCAN_FINISHED);
    return intentFilter;
}
 
Example #19
Source File: ChargeProtector.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean start(Object obj) {
	mReceiver = new ChargeBroadcastReceiver();
	IntentFilter filter = new IntentFilter(Intent.ACTION_POWER_DISCONNECTED);
	getmServiceContext().registerReceiver(mReceiver, filter);
	return true;
}
 
Example #20
Source File: SupervisedUserContentProvider.java    From delion with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void createEnabledBroadcastReceiver() {
    IntentFilter restrictionsFilter = new IntentFilter(
            Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);
    BroadcastReceiver restrictionsReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            updateEnabledState();
        }
    };
    getContext().registerReceiver(restrictionsReceiver, restrictionsFilter);
}
 
Example #21
Source File: RunActivity.java    From SEAL-Demo with MIT License 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(UPDATE_ACTION);
    intentFilter.addAction(AIRPLANE_MODE_ACTION);
    intentFilter.addAction(GPS_PROVIDER_CHANGED_ACTION);
    intentFilter.addAction(KEY_GEN_UPDATE_ACTION);
    intentFilter.addAction(CONNECTIVITY_CHANGED_ACTION);
    registerReceiver(mBroadcastReceiver, intentFilter);
}
 
Example #22
Source File: LocalBroadcastManager.java    From android-sdk with MIT License 5 votes vote down vote up
/**
 * Unregister a previously registered BroadcastReceiver.  <em>All</em>
 * filters that have been registered for this BroadcastReceiver will be
 * removed.
 *
 * @param receiver The BroadcastReceiver to unregister.
 * @see #registerReceiver
 */
public void unregisterReceiver(BroadcastReceiver receiver) {
    synchronized (mReceivers) {
        ArrayList<IntentFilter> filters = mReceivers.remove(receiver);
        if (filters == null) {
            return;
        }
        for (int i = 0; i < filters.size(); i++) {
            IntentFilter filter = filters.get(i);
            for (int j = 0; j < filter.countActions(); j++) {
                String action = filter.getAction(j);
                ArrayList<ReceiverRecord> receivers = mActions.get(action);
                if (receivers != null) {
                    for (int k = 0; k < receivers.size(); k++) {
                        if (receivers.get(k).receiver == receiver) {
                            receivers.remove(k);
                            k--;
                        }
                    }
                    if (receivers.size() <= 0) {
                        mActions.remove(action);
                    }
                }
            }
        }
    }
}
 
Example #23
Source File: HomeActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onStart() {
	super.onStart();
	
	if (!userHasAcceptedTOS()) {
		showTOSAcknowledgement();
	}
	
	mainMenuDelegate = new MainMenuDelegate(this);
	
	requestDataService(new ObjectCallback<KADataService>() {
		@Override
		public void call(KADataService dataService) {
			topic = dataService.getRootTopic();
			if (topic != null) {
				//  It is important to create the AbstractListFragment programmatically here as opposed to
				// specifying it in the xml layout.  If it is specified in xml, we end up with an
				// error about "Content view not yet created" when clicking a list item after restoring
				// a fragment from the back stack.
				setListForTopic(topic, TopicListFragment.class, true);
			}
		}
	});
	
	IntentFilter filter = new IntentFilter();
	filter.addAction(ACTION_LIBRARY_UPDATE);
	filter.addAction(ACTION_BADGE_EARNED);
	filter.addAction(ACTION_TOAST);
	LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter);
}
 
Example #24
Source File: PNetwork.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
@PhonkMethod(description = "Downloads a file from a given Uri. Returns the progress", example = "")
public void downloadWithSystemManager(String url, final ReturnInterface callback) {
    final DownloadManager dm = (DownloadManager) getContext().getSystemService(Context.DOWNLOAD_SERVICE);
    DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
    final long enqueue = dm.enqueue(request);

    BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
                long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
                DownloadManager.Query query = new DownloadManager.Query();
                query.setFilterById(enqueue);
                Cursor c = dm.query(query);
                if (c.moveToFirst()) {
                    int columnIndex = c
                            .getColumnIndex(DownloadManager.COLUMN_STATUS);
                    if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) {
                        if (callback != null) callback.event(null);
                        // callback successful
                    }
                }
            }
        }
    };

    getContext().registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));


}
 
Example #25
Source File: MainActivity.java    From wearable with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //get the widgets
    mybutton = (Button) findViewById(R.id.sendbtn);
    mybutton.setEnabled(false);  //disable until we are connected.
    mybutton.setOnClickListener(this);
    logger = (TextView) findViewById(R.id.logger);

    // Build a new GoogleApiClient that includes the Wearable API
    googleClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
    //once everything is connected, we should be able to send a message.  handled in onConnect.

    //message handler for the send thread.
    handler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            Bundle stuff = msg.getData();
            logthis(stuff.getString("logthis"));
            return true;
        }
    });

    // Register the local broadcast receiver
    IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
    MessageReceiver messageReceiver = new MessageReceiver();
    LocalBroadcastManager.getInstance(this).registerReceiver(messageReceiver, messageFilter);

}
 
Example #26
Source File: SensorTagApplicationClass.java    From SensorTag-CC2650 with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {

    // Use this check to determine whether BLE is supported on the device. Then
    // you can selectively disable BLE-related features.
    if (!getPackageManager().hasSystemFeature(
            PackageManager.FEATURE_BLUETOOTH_LE)) {
        Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_LONG)
                .show();
        mBleSupported = false;
    }

    // Initializes a Bluetooth adapter. For API level 18 and above, get a
    // reference to BluetoothAdapter through BluetoothManager.
    mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    mBtAdapter = mBluetoothManager.getAdapter();

    // Checks if Bluetooth is supported on the device.
    if (mBtAdapter == null) {
        Toast.makeText(this, R.string.bt_not_supported, Toast.LENGTH_LONG).show();
        mBleSupported = false;
        return;
    }

    mFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
    registerReceiver(mReceiver, mFilter);

    if (!mBtAdapter.isEnabled()) {
        Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        enableIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(enableIntent);
    }

    startBluetoothLeService();

    super.onCreate();

}
 
Example #27
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void replacePreferredActivity(IntentFilter filter,
                                     int match, ComponentName[] set, ComponentName activity) {
    try {
        mPM.replacePreferredActivity(filter, match, set, activity, mContext.getUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #28
Source File: AndroidRouter.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public AndroidRouter(UpnpServiceConfiguration configuration,
                     ProtocolFactory protocolFactory,
                     Context context) throws InitializationException {
    super(configuration, protocolFactory);

    this.context = context;
    this.wifiManager = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE));
    this.networkInfo = NetworkUtils.getConnectedNetworkInfo(context);

    // Only register for network connectivity changes if we are not running on emulator
    if (!ModelUtil.ANDROID_EMULATOR) {
        this.broadcastReceiver = new ConnectivityBroadcastReceiver();
        context.registerReceiver(broadcastReceiver, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
    }
}
 
Example #29
Source File: CompoundOrderedBroadcastWithResultReceiver.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    IntentFilter intentFilter = new IntentFilter(CUSTOM_INTENT);
    intentFilter.setPriority(3);
    registerReceiver(mReceiver1, intentFilter);
}
 
Example #30
Source File: SystemSettings.java    From slide-android with GNU General Public License v2.0 5 votes vote down vote up
public boolean isUsbConnected(final Activity a)
{
    final Intent intent = a.registerReceiver(
        null, new IntentFilter(
            "android.hardware.usb.action.USB_STATE")
    );
    return intent != null && intent.getExtras().getBoolean("connected");
}