Question

I am trying to set up a message application such that:

  1. First we set up a message on PreferenceConnector and we receive the message then
  2. BroadcastReceiver checks that the message contents are equal then
  3. I want to get a PendingIntent.
try {
        if (PreferenceConnector.readString(context,"MSG","tempmsg2").equals(messages[0].getMessageBody())) {
            Intent i=new Intent(context, SecureMobiActivity.class);                 
            PendingIntent pi=PendingIntent.getBroadcast(context, 0, i, 0);
        } else {
            Toast.makeText(Remotelock.this, "message are not equal!", Toast.LENGTH_LONG).show();
        }
        catch (Exception e) {
        // TODO: handle exception
            e.printStackTrace();
        }
Was it helpful?

Solution

its answer is so simple

try {
    if (PreferenceConnector.readString(context,"MSG","tempmsg2").equals(messages[0].getMessageBody())) {
        Intent i = new Intent(mContext,SecureMobiActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(i);
    } else {
        Toast.makeText(Remotelock.this, "message are not equal!", Toast.LENGTH_LONG).show();
    }
    catch (Exception e) {
    // TODO: handle exception
        e.printStackTrace();
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top