Example usage for android.app PendingIntent getActivity

List of usage examples for android.app PendingIntent getActivity

Introduction

In this page you can find the example usage for android.app PendingIntent getActivity.

Prototype

public static PendingIntent getActivity(Context context, int requestCode, Intent intent, @Flags int flags) 

Source Link

Document

Retrieve a PendingIntent that will start a new activity, like calling Context#startActivity(Intent) Context.startActivity(Intent) .

Usage

From source file:ru.orangesoftware.financisto.export.flowzr.FlowzrSyncEngine.java

public static String create(Context p_context, DatabaseAdapter p_dba, DefaultHttpClient p_http) {
    startTimestamp = System.currentTimeMillis();

    if (isRunning == true) {
        isCanceled = true;// w  ww.  j a v  a  2 s .  com
        isRunning = false;
    }
    isRunning = true;
    boolean recordSyncTime = true;

    dba = p_dba;
    db = dba.db();
    em = dba.em();
    http_client = p_http;
    context = p_context;

    last_sync_ts = MyPreferences.getFlowzrLastSync(context);
    FLOWZR_BASE_URL = "https://" + MyPreferences.getSyncApiUrl(context);
    FLOWZR_API_URL = FLOWZR_BASE_URL + "/financisto3/";

    nsString = MyPreferences.getFlowzrAccount(context).replace("@", "_"); //urlsafe

    Log.i(TAG, "init sync engine, last sync was " + new Date(last_sync_ts).toLocaleString());
    //if (true) {
    if (!checkSubscriptionFromWeb()) {
        Intent notificationIntent = new Intent(context, FlowzrSyncActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.icon)
                .setTicker(context.getString(R.string.flowzr_subscription_required))
                .setContentTitle(context.getString(R.string.flowzr_sync_error))
                .setContentText(context.getString(R.string.flowzr_subscription_required,
                        MyPreferences.getFlowzrAccount(context)))
                .setContentIntent(pendingIntent).setAutoCancel(true).build();
        notificationManager.notify(0, notification);

        Log.w("flowzr", "subscription rejected from web");
        isCanceled = true;
        MyPreferences.unsetAutoSync(context);
        return null;
    } else {
        mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        // Sets an ID for the notification, so it can be updated

        mNotifyBuilder = new NotificationCompat.Builder(context).setAutoCancel(true)
                .setContentTitle(context.getString(R.string.flowzr_sync))
                .setContentText(context.getString(R.string.flowzr_sync_inprogress))
                .setSmallIcon(R.drawable.icon);
    }

    if (!isCanceled) {
        notifyUser("fix created entities", 5);
        fixCreatedEntities();
    }
    /**
     * pull delete
     */
    if (!isCanceled) {
        notifyUser(context.getString(R.string.flowzr_sync_receiving) + " ...", 10);
        try {
            pullDelete(last_sync_ts);
        } catch (Exception e) {
            sendBackTrace(e);
            recordSyncTime = false;
        }
    }
    /**
     * push delete
     */
    if (!isCanceled) {
        notifyUser(context.getString(R.string.flowzr_sync_sending) + " ...", 15);
        try {
            pushDelete();
        } catch (Exception e) {
            sendBackTrace(e);
            recordSyncTime = false;
        }
    }
    /**
     * pull update
     */
    if (!isCanceled && last_sync_ts == 0) {
        notifyUser(context.getString(R.string.flowzr_sync_receiving) + " ...", 20);
        try {
            pullUpdate();
        } catch (IOException e) {
            sendBackTrace(e);
            recordSyncTime = false;
        } catch (JSONException e) {
            sendBackTrace(e);
            recordSyncTime = false;
        } catch (Exception e) {
            sendBackTrace(e);
            recordSyncTime = false;
        }
    }
    /**
     * push update
     */
    if (!isCanceled) {
        notifyUser(context.getString(R.string.flowzr_sync_sending) + " ...", 35);
        try {
            pushUpdate();
        } catch (ClientProtocolException e) {
            e.printStackTrace();
            sendBackTrace(e);
            recordSyncTime = false;
        } catch (IOException e) {
            e.printStackTrace();
            sendBackTrace(e);
            recordSyncTime = false;
        } catch (JSONException e) {
            e.printStackTrace();
            sendBackTrace(e);
            recordSyncTime = false;
        } catch (Exception e) {
            e.printStackTrace();
            recordSyncTime = false;
        }
    }
    /**
     * pull update
     */
    if (!isCanceled && last_sync_ts > 0) {
        notifyUser(context.getString(R.string.flowzr_sync_receiving) + " ...", 20);
        try {
            pullUpdate();
        } catch (IOException e) {
            sendBackTrace(e);
            recordSyncTime = false;
        } catch (JSONException e) {
            sendBackTrace(e);
            recordSyncTime = false;
        } catch (Exception e) {
            sendBackTrace(e);
            recordSyncTime = false;
        }
    }

    /**
     * send account balances boundaries
     */
    if (!isCanceled) {
        //if (true) { //will generate a Cloud Messaging request if prev. aborted        
        notifyUser(context.getString(R.string.flowzr_sync_sending) + "...", 80);
        //nm.notify(NOTIFICATION_ID, mNotifyBuilder.build()); 
        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("action", "balancesRecalc"));
        nameValuePairs.add(new BasicNameValuePair("last_sync_ts", String.valueOf(last_sync_ts)));
        try {
            httpPush(nameValuePairs, "balances");
        } catch (Exception e) {
            sendBackTrace(e);
        }
    }
    notifyUser(context.getString(R.string.integrity_fix), 85);
    new IntegrityFix(dba).fix();

    notifyUser("Widgets ...", 90);
    AccountWidget.updateWidgets(context);

    Handler refresh = new Handler(Looper.getMainLooper());
    refresh.post(new Runnable() {
        public void run() {
            if (currentActivity != null) {
                //currentActivity.refreshCurrentTab();
            }
        }
    });

    if (!isCanceled && MyPreferences.doGoogleDriveUpload(context)) {
        notifyUser(context.getString(R.string.flowzr_sync_sending) + " Google Drive", 95);
        pushAllBlobs();
    } else {
        Log.i("flowzr", "picture upload desactivated in prefs");
    }
    notifyUser(context.getString(R.string.flowzr_sync_success), 100);
    if (isCanceled == false) {
        if (recordSyncTime == true) {
            last_sync_ts = System.currentTimeMillis();
            SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
            editor.putLong("PROPERTY_LAST_SYNC_TIMESTAMP", last_sync_ts);
            editor.commit();
        }
    }
    //
    mNotificationManager.cancel(NOTIFICATION_ID);
    isRunning = false;
    isCanceled = false;
    if (context instanceof FlowzrSyncActivity) {
        ((FlowzrSyncActivity) context).setIsFinished();
    }
    return FLOWZR_BASE_URL;

}

From source file:org.zywx.wbpalmstar.platform.push.PushRecieveMsgReceiver.java

private void buildPushNotification(Context context, Intent intent, PushDataInfo dataInfo) {
    String title = dataInfo.getTitle();
    String body = dataInfo.getAlert();
    String message = dataInfo.getPushDataString();
    Builder builder = new Builder(context);
    builder.setAutoCancel(true);/*from  w w  w.  j a v  a  2  s.  co  m*/
    builder.setContentTitle(title); // 
    builder.setContentText(body); // 
    builder.setTicker(body); // ??

    String[] remindType = dataInfo.getRemindType();
    if (remindType != null) {
        if (remindType.length == 3) {
            builder.setDefaults(Notification.DEFAULT_ALL);
        } else {
            int defaults = 0;
            for (int i = 0; i < remindType.length; i++) {
                if ("sound".equalsIgnoreCase(remindType[i])) {
                    defaults = Notification.DEFAULT_SOUND;
                    continue;
                }
                if ("shake".equalsIgnoreCase(remindType[i])) {
                    defaults = defaults | Notification.DEFAULT_VIBRATE;
                    continue;
                }
                if ("breathe".equalsIgnoreCase(remindType[i])) {
                    defaults = defaults | Notification.DEFAULT_LIGHTS;
                    continue;
                }
            }
            builder.setDefaults(defaults);
        }
    }

    Resources res = context.getResources();
    int icon = res.getIdentifier("icon", "drawable", intent.getPackage());
    builder.setSmallIcon(icon);
    builder.setWhen(System.currentTimeMillis()); // 

    String iconUrl = dataInfo.getIconUrl();
    boolean isDefaultIcon = !TextUtils.isEmpty(iconUrl) && "default".equalsIgnoreCase(iconUrl);
    Bitmap bitmap = null;
    if (!isDefaultIcon) {
        bitmap = getIconBitmap(context, iconUrl);
    }
    String fontColor = dataInfo.getFontColor();
    RemoteViews remoteViews = null;
    if (!TextUtils.isEmpty(fontColor)) {
        int color = BUtility.parseColor(fontColor);
        int alphaColor = parseAlphaColor(fontColor);
        remoteViews = new RemoteViews(intent.getPackage(), EUExUtil.getResLayoutID("push_notification_view"));
        // Title
        remoteViews.setTextViewText(EUExUtil.getResIdID("notification_title"), title);
        remoteViews.setTextColor(EUExUtil.getResIdID("notification_title"), color);
        // Body
        remoteViews.setTextViewText(EUExUtil.getResIdID("notification_body"), body);
        remoteViews.setTextColor(EUExUtil.getResIdID("notification_body"), alphaColor);
        // LargeIcon
        if (bitmap != null) {
            remoteViews.setImageViewBitmap(EUExUtil.getResIdID("notification_largeIcon"), bitmap);
        } else {
            remoteViews.setImageViewResource(EUExUtil.getResIdID("notification_largeIcon"),
                    EUExUtil.getResDrawableID("icon"));
        }
        // Time
        SimpleDateFormat format = new SimpleDateFormat("HH:mm");
        remoteViews.setTextViewText(EUExUtil.getResIdID("notification_time"),
                format.format(System.currentTimeMillis()));
        remoteViews.setTextColor(EUExUtil.getResIdID("notification_time"), alphaColor);
        builder.setContent(remoteViews);
    }

    Intent notiIntent = new Intent(context, EBrowserActivity.class);
    notiIntent.putExtra("ntype", F_TYPE_PUSH);
    notiIntent.putExtra("data", body);
    notiIntent.putExtra("message", message);
    Bundle bundle = new Bundle();
    bundle.putSerializable(PushReportConstants.PUSH_DATA_INFO_KEY, dataInfo);
    notiIntent.putExtras(bundle);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationNB, notiIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(pendingIntent);

    NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = builder.build();
    // Android v4bug2.3?Builder?NotificationRemoteView??
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && remoteViews != null) {
        notification.contentView = remoteViews;
    }
    manager.notify(notificationNB, notification);
    notificationNB++;
}

From source file:ru.appsm.inapphelp.IAHHelpDesk.java

/**
 *
 * Handle push notification. Cordova./*from  w w  w. jav a  2  s. com*/
 *
 * @param data
 * @param context
 */
public static void BuildNotificationForDataWithContext(JSONObject data, Context context) {
    Log.i(TAG, "Create notifications");
    if (data != null && data.has("secretkey") && data.has("userid") && data.has("appkey") && data.has("appid")
            && data.has("email") && data.has("message") && data.has("title") && data.has("notId")
            && data.has("msgId")) {
        try {
            int notId = 1;
            try {
                notId = data.getInt("notId");
            } catch (JSONException e) {
                notId = 1;
            }

            mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            Intent notificationIntent = new Intent(context, IssueDetailActivity.class);
            notificationIntent.putExtra("fromPush", true);
            notificationIntent.putExtra("userid", data.getString("userid"));
            notificationIntent.putExtra("appid", data.getString("appid"));
            notificationIntent.putExtra("appkey", data.getString("appkey"));
            notificationIntent.putExtra("secretkey", data.getString("secretkey"));
            notificationIntent.putExtra("email", data.getString("email"));

            PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                    .setSmallIcon(getApplicationIcon(context)).setContentTitle(data.getString("title"))
                    .setContentText(data.getString("message")).setAutoCancel(true)
                    .setContentIntent(contentIntent);

            if (data.getString("sound").equals("default")) {
                mBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE
                        | Notification.DEFAULT_LIGHTS);
            }

            mNotificationManager.notify(notId, mBuilder.build());
        } catch (JSONException e) {
            Log.i(TAG, "Fail to parse push data");
        }
    } else {
        Log.i(TAG, "Empty or wrong push data");
    }
}

From source file:fr.bmartel.android.iotf.app.BaseActivity.java

/**
 * create a notification with defined message
 *
 * @param message notification message/*  www. j  ava2 s.  c o m*/
 */
protected void triggerNotification(String message) {

    Intent intent = new Intent(this, ConnectActivity.class);
    PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);

    android.support.v4.app.NotificationCompat.Builder n = new android.support.v4.app.NotificationCompat.Builder(
            this).setContentTitle("iotf notification").setContentText(message).setSmallIcon(R.drawable.app_icon)
                    .setContentIntent(pIntent).setVibrate(new long[] { 1000, 1000 }).setAutoCancel(true);

    screenLock.acquire();

    if (ringtone != null)
        ringtone.play();

    notifyMgr.notify(0, n.build());
}

From source file:com.onesignal.GenerateNotification.java

private static PendingIntent getNewActionPendingIntent(int requestCode, Intent intent) {
    if (openerIsBroadcast)
        return PendingIntent.getBroadcast(currentContext, requestCode, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
    return PendingIntent.getActivity(currentContext, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}

From source file:com.netease.qa.emmagee.service.EmmageeService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i(LOG_TAG, "service onStart");
    PendingIntent contentIntent = PendingIntent.getActivity(getBaseContext(), 0,
            new Intent(this, MainPageActivity.class), 0);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setContentIntent(contentIntent).setSmallIcon(R.drawable.icon).setWhen(System.currentTimeMillis())
            .setAutoCancel(true).setContentTitle("ETest");
    startForeground(startId, builder.build());

    HttpUtils.testSuitId = 0;/*  w w w.  ja va2s.  c  om*/
    pid = intent.getExtras().getInt("pid");
    uid = intent.getExtras().getInt("uid");
    processName = intent.getExtras().getString("processName");
    packageName = intent.getExtras().getString("packageName");
    startActivity = intent.getExtras().getString("startActivity");
    appVersion = intent.getExtras().getString("appVersion");

    cpuInfo = new CpuInfo(getBaseContext(), pid, Integer.toString(uid));
    readSettingInfo();
    if (isFloating) {
        viFloatingWindow = LayoutInflater.from(this).inflate(R.layout.floating, null);
        txtUnusedMem = (TextView) viFloatingWindow.findViewById(R.id.memunused);
        txtTotalMem = (TextView) viFloatingWindow.findViewById(R.id.memtotal);
        txtTraffic = (TextView) viFloatingWindow.findViewById(R.id.traffic);
        btnWifi = (Button) viFloatingWindow.findViewById(R.id.wifi);

        wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        if (wifiManager.isWifiEnabled()) {
            btnWifi.setText(R.string.close_wifi);
        } else {
            btnWifi.setText(R.string.open_wifi);
        }
        txtUnusedMem.setText(getString(R.string.calculating));
        txtUnusedMem.setTextColor(android.graphics.Color.RED);
        txtTotalMem.setTextColor(android.graphics.Color.RED);
        txtTraffic.setTextColor(android.graphics.Color.RED);
        btnStop = (Button) viFloatingWindow.findViewById(R.id.stop);
        btnStop.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("isServiceStop", true);
                intent.setAction(SERVICE_ACTION);
                sendBroadcast(intent);

                stopSelf();
            }
        });
        createFloatingWindow();
    }
    createResultCsv();
    if (isRoot) {
        getlog();
    }
    handler.postDelayed(task, 1000);
    return START_NOT_STICKY;
}

From source file:com.example.android.basicsyncadapter.SyncAdapter.java

/**
 * Called by the Android system in response to a request to run the sync adapter. The work required to read data from the network,
 * parse it, and store it in the content provider is done here. Extending AbstractThreadedSyncAdapter ensures that all methods
 * within SyncAdapter run on a background thread. For this reason, blocking I/O and other long-running tasks can be run
 * <em>in situ</em>, and you don't have to set up a separate thread for them.
 *
 * <p>This is where we actually perform any work required to perform a sync. {@link android.content.AbstractThreadedSyncAdapter}
 * guarantees that this will be called on a non-UI thread, so it is safe to peform blocking I/O here.
 *
 * <p>The syncResult argument allows you to pass information back to the method that triggered the sync.
 *//*from  w  w  w  .jav  a 2  s.  c  om*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
        SyncResult syncResult) {
    Log.i(TAG, "Beginning network synchronization");
    try {
        InputStream stream = null;

        try {
            //Log.i(TAG, "Streaming data from network: " + FEED_URL);
            //stream = downloadUrl(location);
            stream = downloadUrl(FEED_URL);
            updateLocalFeedData(stream, syncResult);
        } finally {
            if (stream != null) {
                stream.close();
            }
        }
    } catch (MalformedURLException e) {
        Log.e(TAG, "Feed URL is malformed", e);
        syncResult.stats.numParseExceptions++;
        return;
    } catch (IOException e) {
        Log.e(TAG, "Error reading from network: " + e.toString());
        syncResult.stats.numIoExceptions++;
        return;
    } catch (XmlPullParserException e) {
        Log.e(TAG, "Error parsing feed: " + e.toString());
        syncResult.stats.numParseExceptions++;
        return;
    } catch (ParseException e) {
        Log.e(TAG, "Error parsing feed: " + e.toString());
        syncResult.stats.numParseExceptions++;
        return;
    } catch (RemoteException e) {
        Log.e(TAG, "Error updating database: " + e.toString());
        syncResult.databaseError = true;
        return;
    } catch (OperationApplicationException e) {
        Log.e(TAG, "Error updating database: " + e.toString());
        syncResult.databaseError = true;
        return;
    }
    Log.i(TAG, "Network synchronization complete");

    //Throw notification

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getContext())
            .setSmallIcon(R.drawable.ic_launcher).setContentTitle("Alerta de cicln tropical")
            .setContentText("Hello World!").setAutoCancel(true).setLights(0xff00ff00, 300, 100)
            .setPriority(Notification.PRIORITY_MAX);

    Intent resultIntent = new Intent(getContext(), EntryListActivity.class);
    PendingIntent resultPendingIntent = PendingIntent.getActivity(getContext(), 0, resultIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    //Add sound
    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    //Add vibrate pattern
    long[] pattern = { 0, 200, 500 };

    mBuilder.setVibrate(pattern);
    mBuilder.setSound(alarmSound);
    mBuilder.setContentIntent(resultPendingIntent);

    int mNotificationId = 001;
    NotificationManager mNotifyMgr = (NotificationManager) getContext()
            .getSystemService(Service.NOTIFICATION_SERVICE);
    mNotifyMgr.notify(mNotificationId, mBuilder.build());

    //Wake screen
    /*WakeLock screenOn = ((PowerManager)getContext().getSystemService(Service.POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK| PowerManager.ACQUIRE_CAUSES_WAKEUP, "example");
    screenOn.acquire();
            
    long endTime = System.currentTimeMillis() + 6*1000;
    while (System.currentTimeMillis() < endTime) {
    synchronized (this) {
        try {
            wait(endTime - System.currentTimeMillis());
        } catch (Exception e) {
        }
    }
    }
            
    screenOn.release();*/
}

From source file:org.droidkit.app.UpdateService.java

private void notifyUser(String json) {
    Intent intent = new Intent(this, UpdateActivity.class);
    intent.putExtra("json", json);

    String desc = "Update available for " + getString(getApplicationInfo().labelRes);

    PendingIntent pending = PendingIntent.getActivity(this, 0, intent, 0);
    Notification n = new Notification(android.R.drawable.stat_sys_download_done, "Update available",
            System.currentTimeMillis());
    n.setLatestEventInfo(this, "Update Available", desc, pending);

    mNotificationManager.notify("Update Available", UPDATE_SERVICE_ID, n);
}

From source file:com.vidinoti.pixlive.PixLive.java

static void startSDK(final Context c) {

    if (VDARSDKController.getInstance() != null) {
        return;/* ww w . j  a  v  a 2 s.com*/
    }

    String storage = c.getApplicationContext().getFilesDir().getAbsolutePath() + "/pixliveSDK";

    String licenseKey = null;

    try {
        ApplicationInfo ai = c.getPackageManager().getApplicationInfo(c.getPackageName(),
                PackageManager.GET_META_DATA);
        Bundle bundle = ai.metaData;
        licenseKey = bundle.getString("com.vidinoti.pixlive.LicenseKey");
    } catch (PackageManager.NameNotFoundException e) {
        Log.e(TAG, "Unable to start PixLive SDK without valid storage and license key.");
        return;
    } catch (NullPointerException e) {
        Log.e(TAG, "Unable to start PixLive SDK without valid storage and license key.");
        return;
    }

    if (storage == null || licenseKey == null) {
        Log.e(TAG, "Unable to start PixLive SDK without valid storage and license key.");
        return;
    }

    VDARSDKController.startSDK(c, storage, licenseKey);

    /* Comment out to disable QR code detection */
    VDARSDKController.getInstance().setEnableCodesRecognition(true);

    VDARSDKController.getInstance().setNotificationFactory(new NotificationFactory() {

        @Override
        public Notification createNotification(String title, String message, String notificationID) {

            Intent appIntent = c.getPackageManager().getLaunchIntentForPackage(c.getPackageName());

            appIntent.putExtra("nid", notificationID);
            appIntent.putExtra("remote", false);

            PendingIntent contentIntent = PendingIntent.getActivity(c, 0, appIntent,
                    PendingIntent.FLAG_UPDATE_CURRENT);

            ApplicationInfo ai = c.getApplicationInfo();

            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(c)
                    .setSmallIcon(ai.icon != 0 ? ai.icon : android.R.drawable.star_big_off)
                    .setContentTitle(title).setContentText(message).setContentIntent(contentIntent)
                    .setAutoCancel(true).setVibrate(new long[] { 100, 200, 200, 400 })
                    .setLights(Color.BLUE, 500, 1500);

            mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

            return mBuilder.getNotification();
        }
    });
}

From source file:net.helff.wificonnector.WifiConnectivityService.java

protected void sendNotification(String msg) {
    Log.i(TAG, "send notification: " + msg);
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    Notification notification = new Notification(R.drawable.launchericon, msg, System.currentTimeMillis());

    Intent intent = new Intent(this, WifiConnectorActivity.class);
    intent.setAction("android.intent.action.MAIN");
    intent.addCategory("android.intent.category.LAUNCHER");
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

    notification.setLatestEventInfo(this.getApplicationContext(), "WifiConnector", msg, pendingIntent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notificationManager.notify(1, notification);

}