Search in sources :

Example 66 with PendingIntent

use of android.app.PendingIntent in project XPrivacy by M66B.

the class BootReceiver method onReceive.

@Override
public void onReceive(final Context context, Intent bootIntent) {
    // Start boot update
    Intent changeIntent = new Intent();
    changeIntent.setClass(context, UpdateService.class);
    changeIntent.putExtra(UpdateService.cAction, UpdateService.cActionBoot);
    context.startService(changeIntent);
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    // Check if Xposed enabled
    if (Util.isXposedEnabled() && PrivacyService.checkClient())
        try {
            if (PrivacyService.getClient().databaseCorrupt()) {
                // Build notification
                NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
                notificationBuilder.setSmallIcon(R.drawable.ic_launcher);
                notificationBuilder.setContentTitle(context.getString(R.string.app_name));
                notificationBuilder.setContentText(context.getString(R.string.msg_corrupt));
                notificationBuilder.setWhen(System.currentTimeMillis());
                notificationBuilder.setAutoCancel(true);
                Notification notification = notificationBuilder.build();
                // Display notification
                notificationManager.notify(Util.NOTIFY_CORRUPT, notification);
            } else
                context.sendBroadcast(new Intent("biz.bokhorst.xprivacy.action.ACTIVE"));
        } catch (Throwable ex) {
            Util.bug(null, ex);
        }
    else {
        // Create Xposed installer intent
        // @formatter:off
        Intent xInstallerIntent = new Intent("de.robv.android.xposed.installer.OPEN_SECTION").setPackage("de.robv.android.xposed.installer").putExtra("section", "modules").putExtra("module", context.getPackageName()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // @formatter:on
        PendingIntent pi = (xInstallerIntent == null ? null : PendingIntent.getActivity(context, 0, xInstallerIntent, PendingIntent.FLAG_UPDATE_CURRENT));
        // Build notification
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
        notificationBuilder.setSmallIcon(R.drawable.ic_launcher);
        notificationBuilder.setContentTitle(context.getString(R.string.app_name));
        notificationBuilder.setContentText(context.getString(R.string.app_notenabled));
        notificationBuilder.setWhen(System.currentTimeMillis());
        notificationBuilder.setAutoCancel(true);
        if (pi != null)
            notificationBuilder.setContentIntent(pi);
        Notification notification = notificationBuilder.build();
        // Display notification
        notificationManager.notify(Util.NOTIFY_NOTXPOSED, notification);
    }
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 67 with PendingIntent

use of android.app.PendingIntent in project XPrivacy by M66B.

the class XLocationManager method proxyLocationListener.

private void proxyLocationListener(XParam param, int arg, Class<?> interfaze, boolean client) throws Throwable {
    if (param.args.length > arg)
        if (param.args[arg] instanceof PendingIntent)
            param.setResult(null);
        else if (param.args[arg] != null && param.thisObject != null) {
            if (client) {
                Object key = param.args[arg];
                synchronized (mMapProxy) {
                    // Reuse existing proxy
                    if (mMapProxy.containsKey(key)) {
                        Util.log(this, Log.INFO, "Reuse existing proxy uid=" + Binder.getCallingUid());
                        param.args[arg] = mMapProxy.get(key);
                        return;
                    }
                    // Already proxied
                    if (mMapProxy.containsValue(key)) {
                        Util.log(this, Log.INFO, "Already proxied uid=" + Binder.getCallingUid());
                        return;
                    }
                }
                // Create proxy
                Util.log(this, Log.INFO, "Creating proxy uid=" + Binder.getCallingUid());
                Object proxy = new ProxyLocationListener(Binder.getCallingUid(), (LocationListener) param.args[arg]);
                // Use proxy
                synchronized (mMapProxy) {
                    mMapProxy.put(key, proxy);
                }
                param.args[arg] = proxy;
            } else {
                // Create proxy
                ClassLoader cl = param.thisObject.getClass().getClassLoader();
                InvocationHandler ih = new OnLocationChangedHandler(Binder.getCallingUid(), param.args[arg]);
                Object proxy = Proxy.newProxyInstance(cl, new Class<?>[] { interfaze }, ih);
                Object key = param.args[arg];
                if (key instanceof IInterface)
                    key = ((IInterface) key).asBinder();
                // Use proxy
                synchronized (mMapProxy) {
                    mMapProxy.put(key, proxy);
                }
                param.args[arg] = proxy;
            }
        }
}
Also used : IInterface(android.os.IInterface) PendingIntent(android.app.PendingIntent) InvocationHandler(java.lang.reflect.InvocationHandler)

Example 68 with PendingIntent

use of android.app.PendingIntent in project MWM-for-Android-Gen1 by MetaWatchOpenProjects.

the class MetaWatchService method createNotification.

public void createNotification() {
    notification = new android.app.Notification(R.drawable.disconnected_large, null, System.currentTimeMillis());
    notification.flags |= android.app.Notification.FLAG_ONGOING_EVENT;
    remoteViews = new RemoteViews(getPackageName(), R.layout.notification);
    remoteViews.setImageViewResource(R.id.image, R.drawable.disconnected);
    remoteViews.setTextViewText(R.id.text, "MetaWatch service is running");
    notification.contentView = remoteViews;
    Intent notificationIntent = new Intent(this, MetaWatch.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    notification.contentIntent = contentIntent;
    startForeground(1, notification);
}
Also used : RemoteViews(android.widget.RemoteViews) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 69 with PendingIntent

use of android.app.PendingIntent in project FileExplorer by MiCode.

the class FTPServerService method setupNotification.

private void setupNotification() {
    // http://developer.android.com/guide/topics/ui/notifiers/notifications.html
    // Instantiate a Notification
    int icon = R.drawable.notification;
    CharSequence tickerText = getString(R.string.notif_server_starting);
    long when = System.currentTimeMillis();
    Notification notification = new Notification(icon, tickerText, when);
    // Define Notification's message and Intent
    CharSequence contentTitle = getString(R.string.notif_title);
    CharSequence contentText = "";
    InetAddress address = FTPServerService.getWifiIp();
    if (address != null) {
        String port = ":" + FTPServerService.getPort();
        contentText = "ftp://" + address.getHostAddress() + (FTPServerService.getPort() == 21 ? "" : port);
    }
    Intent notificationIntent = new Intent(this, FileExplorerTabActivity.class);
    notificationIntent.putExtra(GlobalConsts.INTENT_EXTRA_TAB, 2);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    notification.setLatestEventInfo(getApplicationContext(), contentTitle, contentText, contentIntent);
    notification.flags |= Notification.FLAG_ONGOING_EVENT;
    startForeground(123453, notification);
    myLog.d("Notication setup done");
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) InetAddress(java.net.InetAddress) Notification(android.app.Notification)

Example 70 with PendingIntent

use of android.app.PendingIntent in project Notes by MiCode.

the class AlarmInitReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    long currentDate = System.currentTimeMillis();
    Cursor c = context.getContentResolver().query(Notes.CONTENT_NOTE_URI, PROJECTION, NoteColumns.ALERTED_DATE + ">? AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE, new String[] { String.valueOf(currentDate) }, null);
    if (c != null) {
        if (c.moveToFirst()) {
            do {
                long alertDate = c.getLong(COLUMN_ALERTED_DATE);
                Intent sender = new Intent(context, AlarmReceiver.class);
                sender.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, c.getLong(COLUMN_ID)));
                PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, sender, 0);
                AlarmManager alermManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
                alermManager.set(AlarmManager.RTC_WAKEUP, alertDate, pendingIntent);
            } while (c.moveToNext());
        }
        c.close();
    }
}
Also used : AlarmManager(android.app.AlarmManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Cursor(android.database.Cursor)

Aggregations

PendingIntent (android.app.PendingIntent)1208 Intent (android.content.Intent)1010 Notification (android.app.Notification)222 NotificationCompat (android.support.v4.app.NotificationCompat)167 AlarmManager (android.app.AlarmManager)149 NotificationManager (android.app.NotificationManager)148 Bundle (android.os.Bundle)75 RemoteViews (android.widget.RemoteViews)67 RemoteException (android.os.RemoteException)64 Resources (android.content.res.Resources)62 Bitmap (android.graphics.Bitmap)61 Context (android.content.Context)60 ComponentName (android.content.ComponentName)55 Test (org.junit.Test)44 Uri (android.net.Uri)42 IntentFilter (android.content.IntentFilter)41 SharedPreferences (android.content.SharedPreferences)36 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)33 UserHandle (android.os.UserHandle)31 ArrayList (java.util.ArrayList)30