List of usage examples for android.content Intent EXTRA_UID
String EXTRA_UID
To view the source code for android.content Intent EXTRA_UID.
Click Source Link
From source file:eu.faircode.netguard.ReceiverPackageRemoved.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);// w w w . ja v a2s . co m int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { DatabaseHelper dh = DatabaseHelper.getInstance(context); dh.clearLog(uid); dh.clearAccess(uid, false); NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } }
From source file:eu.faircode.adblocker.Receiver.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);/*w w w. j av a 2s .c o m*/ if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context)) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } } } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Application removed Rule.clearCache(context); if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) { // Remove settings String packageName = intent.getData().getSchemeSpecificPart(); Log.i(TAG, "Deleting settings package=" + packageName); context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply(); int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } } } else { // Upgrade settings upgrade(true, context); // Start service SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); try { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false)) ServiceSinkhole.start("receiver", context); } else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false)) ServiceSinkhole.start("receiver", context); else if (prefs.getBoolean("show_stats", false)) ServiceSinkhole.run("receiver", context); } } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, context); } if (Util.isInteractive(context)) ServiceSinkhole.reloadStats("receiver", context); } }
From source file:com.zhengde163.netguard.Receiver.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);//ww w.j a va 2s . c o m SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification if (prefs.getBoolean("install", true)) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } } } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Application removed Rule.clearCache(context); if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) { // Remove settings String packageName = intent.getData().getSchemeSpecificPart(); Log.i(TAG, "Deleting settings package=" + packageName); context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply(); int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { DatabaseHelper.getInstance(context).clearAccess(uid, false); NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } } } else { // Upgrade settings upgrade(true, context); // Start service try { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false)) ServiceSinkhole.start("receiver", context); } else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false)) ServiceSinkhole.start("receiver", context); else if (prefs.getBoolean("show_stats", false)) ServiceSinkhole.run("receiver", context); } } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, context); } if (Util.isInteractive(context)) ServiceSinkhole.reloadStats("receiver", context); } }
From source file:eu.faircode.netguard.Receiver.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);/*from ww w .j av a 2 s. co m*/ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context) && prefs.getBoolean("install", true)) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } } } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Application removed Rule.clearCache(context); if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) { // Remove settings String packageName = intent.getData().getSchemeSpecificPart(); Log.i(TAG, "Deleting settings package=" + packageName); context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply(); int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { DatabaseHelper.getInstance(context).clearAccess(uid, false); NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } } } else { // Upgrade settings upgrade(true, context); // Start service try { if (prefs.getBoolean("enabled", false)) ServiceSinkhole.start("receiver", context); else if (prefs.getBoolean("show_stats", false)) ServiceSinkhole.run("receiver", context); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } if (Util.isInteractive(context)) ServiceSinkhole.reloadStats("receiver", context); } }
From source file:com.master.metehan.filtereagle.Receiver.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);/*w w w . j a v a 2 s . com*/ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context) && prefs.getBoolean("install", true)) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } } } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Application removed Rule.clearCache(context); if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) { // Remove settings String packageName = intent.getData().getSchemeSpecificPart(); Log.i(TAG, "Deleting settings package=" + packageName); context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply(); int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { DatabaseHelper.getInstance(context).clearAccess(uid, false); NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } } } else { // Upgrade settings upgrade(true, context); // Start service try { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false)) ServiceSinkhole.start("receiver", context); } else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false)) ServiceSinkhole.start("receiver", context); else if (prefs.getBoolean("show_stats", false)) ServiceSinkhole.run("receiver", context); } } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, context); } if (Util.isInteractive(context)) ServiceSinkhole.reloadStats("receiver", context); } }
From source file:android_network.hetnet.vpn_service.Receiver.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);//from www. j a v a 2s . c o m SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification if (true) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } } } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Application removed Rule.clearCache(context); if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) { // Remove settings String packageName = intent.getData().getSchemeSpecificPart(); Log.i(TAG, "Deleting settings package=" + packageName); context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply(); int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { DatabaseHelper.getInstance(context).clearAccess(uid, false); NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } } } else { // Upgrade settings upgrade(true, context); // Start service try { if (prefs.getBoolean("enabled", false)) ServiceSinkhole.start("receiver", context); else if (prefs.getBoolean("show_stats", false)) ServiceSinkhole.run("receiver", context); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } if (Util.isInteractive(context)) ServiceSinkhole.reloadStats("receiver", context); } }
From source file:dev.ukanth.ufirewall.PackageBroadcast.java
@Override public void onReceive(Context context, Intent intent) { Uri inputUri = Uri.parse(intent.getDataString()); if (!inputUri.getScheme().equals("package")) { Log.d("AFWall+", "Intent scheme was not 'package'"); return;/* ww w.j a v a 2s .c o m*/ } if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Ignore application updates final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false); if (!replacing) { // Update the Firewall if necessary final int uid = intent.getIntExtra(Intent.EXTRA_UID, -123); Api.applicationRemoved(context, uid); /*Api.applicationRemoved(context, inputUri.getSchemeSpecificPart());*/ // Force app list reload next time Api.applications = null; } } else if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { final boolean updateApp = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false); if (updateApp) { // dont do anything //1 check the package already added in firewall } else { // Force app list reload next time Api.applications = null; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean isNotify = prefs.getBoolean("notifyAppInstall", false); if (isNotify && Api.isEnabled(context)) { String added_package = intent.getData().getSchemeSpecificPart(); if (PackageManager.PERMISSION_GRANTED == context.getPackageManager() .checkPermission(Manifest.permission.INTERNET, added_package)) { notifyApp(context, intent, added_package); } } } } }
From source file:dev.ukanth.ufirewall.broadcast.PackageBroadcast.java
@Override public void onReceive(Context context, Intent intent) { Uri inputUri = Uri.parse(intent.getDataString()); if (!inputUri.getScheme().equals("package")) { Log.d("AFWall+", "Intent scheme was not 'package'"); return;// w w w.jav a 2 s . c om } if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Ignore application updates final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false); if (!replacing) { // Update the Firewall if necessary final int uid = intent.getIntExtra(Intent.EXTRA_UID, -123); Api.applicationRemoved(context, uid); Api.removeCacheLabel(intent.getData().getSchemeSpecificPart(), context); // Force app list reload next time Api.applications = null; } } else if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { final boolean updateApp = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false); if (updateApp) { // dont do anything //1 check the package already added in firewall } else { // Force app list reload next time Api.applications = null; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean isNotify = prefs.getBoolean("notifyAppInstall", false); if (isNotify && Api.isEnabled(context)) { String added_package = intent.getData().getSchemeSpecificPart(); final PackageManager pkgmanager = context.getPackageManager(); String label = null; try { label = pkgmanager.getApplicationLabel(pkgmanager.getApplicationInfo(added_package, 0)) .toString(); } catch (NameNotFoundException e) { } if (PackageManager.PERMISSION_GRANTED == pkgmanager .checkPermission(Manifest.permission.INTERNET, added_package)) { notifyApp(context, intent, label); } } } } }
From source file:com.intuitlabs.wear.voiceandchoice.ActionReceiver.java
/** * {@inheritDoc}/*www .ja v a2s . c om*/ */ @Override public void onReceive(final Context context, final Intent _intent) { /** notificationId used to issue the notification, so we can cancel the notification */ final int notificationId = _intent.getIntExtra(Intent.EXTRA_UID, -1); /** The bundle that was created during the speech recognition process */ final Bundle remoteInput = RemoteInput.getResultsFromIntent(_intent); /* The user's choice, either directly selected or as a speech recognition result. */ final String reply = remoteInput != null ? remoteInput.getCharSequence(AndroidNotification.EXTRA_VOICE_REPLY).toString() : ""; /* The integer value, associated with the command string in the original json document that was used to generate the notification */ @SuppressWarnings("unchecked") final Map<String, Integer> cmdkeys = (Map<String, Integer>) ListStyle.readFromSharedPreference(context); final int selectedId = new PhoneticSearch<>(cmdkeys).match(reply); Log.v(LOG_TAG, "Selection / Speech Recognition result: " + reply); Log.i(LOG_TAG, "Selection / Selected ID " + selectedId); /* Cancel the Notification, which makes it disappear on phone and watch */ final NotificationManager manager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); manager.cancel(notificationId); switch (selectedId) { // Purchase Turbo Tax / Go to Web Page case 0: case 4: final String url = context.getString(R.string.turbotax_url); context.startActivity( new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); break; // create a calendar Event case 1: case 5: final Calendar cal = Calendar.getInstance(); cal.set(2015, 3, 15); final Intent intent = new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI) .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, cal.getTimeInMillis()) .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, cal.getTimeInMillis() + 60 * 60 * 1000) .putExtra(CalendarContract.Events.TITLE, context.getString(R.string.turbotax_title)) .putExtra(CalendarContract.Events.DESCRIPTION, context.getString(R.string.turbotax_description)) .putExtra(CalendarContract.Events.EVENT_LOCATION, context.getString(R.string.turbotax_location)) .putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY) .putExtra(Intent.EXTRA_EMAIL, context.getString(R.string.turbotax_email)) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); break; // set a reminder case 2: case 6: // todo, set a reminder .. break; // dismiss, do nothing case 3: case 7: default: } }
From source file:fr.android.scaron.diaspdroid.vues.fragment.CommentsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { String TAG_METHOD = TAG + ".onCreate : "; LOG.d(TAG_METHOD + "Entre"); try {// w w w . jav a 2 s. c om super.onCreate(savedInstanceState); footerView = ((LayoutInflater) getActivity().getBaseContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.base_list_item_loading_footer, null, false); if (this.getArguments() != null) { Integer postID = this.getArguments().getInt(Intent.EXTRA_UID); LOG.d(TAG_METHOD + "postID is null ? " + (postID == null)); LOG.d(TAG_METHOD + "call getPodsService"); getComments(postID); } LOG.d(TAG_METHOD + "Sortie"); } catch (Throwable thr) { LOG.e(TAG_METHOD + "Erreur : " + thr.toString()); ACRA.getErrorReporter().handleException(thr); LOG.d(TAG_METHOD + "Sortie en erreur"); throw thr; } }