提出项目目标时,SetEventLatestInfo不起作用

时间:2019-04-05 11:14:18

标签: android notifications alarmmanager

当项目目标低于13时,Notification_quote.java文件可以正常工作。Sdk目标不再为26。但是会出现错误。并且无法运行。我在附件中发送Notification_quote.java。如果您能帮助我执行此操作,我将不胜感激。谢谢。我只是在学习编码。可以告诉我如何更新的人可以使我免于遇到大麻烦。 :)

public Notification_Quote()
{
    getQuote = null;
}

private boolean isServiceRunning(String s, Context context)
{
    boolean flag1 = false;
    Iterator iterator = ((ActivityManager)context.getSystemService("activity")).getRunningAppProcesses().iterator();
    do
    {
        do
        {
            if (!iterator.hasNext())
            {
                return flag1;
            }
        } while (!((android.app.ActivityManager.RunningAppProcessInfo)iterator.next()).processName.equals(s));
        flag1 = true;
    } while (true);
}

public void onReceive(Context context, Intent intent1)
{
    l_time = Long.valueOf(PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()).getLong("calendar_value", 0L));
    DatabaseHelper databasehelper = new DatabaseHelper(context);
    helper = databasehelper;
    helper.createDatabase();
    helper.openDataBase();
    getQuote = helper.getRandomQuote(1, "");
    if (getQuote != null)
    {
        getQuote.moveToFirst();
        do
        {
            Quote_id = getQuote.getInt(0);
            Quotename = getQuote.getString(1).toString();
        } while (getQuote.moveToNext());
    }
    getQuote.close();
    String s;
    String s1;
    Intent intent2;
    PendingIntent pendingintent;
    Notification notification;
    Editor editor;
    try
    {
        helper.close();
    }
    catch (NullPointerException nullpointerexception5)
    {
        if (nullpointerexception5.getMessage() != null)
        {
            Log.e("null pointer ERROR", nullpointerexception5.getMessage());
        }
    }
    catch (Exception exception6)
    {
        if (exception6.getMessage() != null)
        {
            Log.e("ERROR", exception6.getMessage());
        }
    }
    nm = (NotificationManager)context.getSystemService("notification");
    s = context.getString(R.string.app_name);
    s1 = Quotename;
    intent2 = new Intent(context, Single_Quote.class);
    intent2.putExtra((new StringBuilder(String.valueOf(context.getPackageName()))).append(".quote_day").toString(), 2);
    if (isServiceRunning(context.getPackageName(), context))
    {
        flag = 0x4000000;
    } else
    {
        flag = 0x10000000;
    }
    pendingintent = PendingIntent.getActivity(context, 0, intent2, 0);
    notification = new Notification(R.drawable.ic_launcher, s1, System.currentTimeMillis());
    notification.setLatestEventInfo(context, s, s1, pendingintent);
    notification.vibrate = (new long[] {
        100L, 250L, 100L, 500L
    });
    notification.flags = 0x19 | notification.flags;
    editor = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()).edit();
    editor.putInt("Qid", Quote_id);
    editor.commit();
    nm.notify(1, notification);
    return;

}

}

0 个答案:

没有答案