Файл Notification_quote.java работает нормально, если цель проекта не достигла 13 лет. Цель 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;
}
}