diff --git a/app/src/main/java/com/example/notifyservice/Listener.java b/app/src/main/java/com/example/notifyservice/Listener.java index 7c3d033..f3c39d3 100644 --- a/app/src/main/java/com/example/notifyservice/Listener.java +++ b/app/src/main/java/com/example/notifyservice/Listener.java @@ -59,7 +59,8 @@ public class Listener extends NotificationListenerService { String code = processExtras(sbn.getNotification().extras); if (code.length() < 5) return; - Intent intent = new Intent(getApplicationContext().getPackageName() + ".NOTIFICATION_RECEIVED"); // STATIC + Intent intent = new Intent(getApplicationContext().getPackageName() + "." + // STATIC + "NOTIFICATION_RECEIVED"); intent.putExtra("code", code); sendBroadcast(intent); } diff --git a/app/src/main/java/com/example/notifyservice/MainActivity.java b/app/src/main/java/com/example/notifyservice/MainActivity.java index e96195d..52a11bd 100644 --- a/app/src/main/java/com/example/notifyservice/MainActivity.java +++ b/app/src/main/java/com/example/notifyservice/MainActivity.java @@ -129,12 +129,14 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba protected void onCreate(Bundle savedInstanceState) { Log.i("a", "1"); // STATIC super.onCreate(savedInstanceState); + notificationReceiver = new NotificationReceiver(); setContentView(R.layout.activity_main); webView = findViewById(R.id.webview); mainContainer = findViewById(android.R.id.content); + WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); @@ -288,9 +290,8 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba } else if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){ Intent intent = new Intent(this, Listener.class); startService(intent); - - notificationReceiver = new NotificationReceiver(); - IntentFilter filter = new IntentFilter(getApplicationContext().getPackageName() + ".NOTIFICATION_RECEIVED"); // STATIC + IntentFilter filter = new IntentFilter(getApplicationContext().getPackageName() + "." + // STATIC + "NOTIFICATION_RECEIVED"); registerReceiver(notificationReceiver, filter); registerReceiver(smsReceiver, new IntentFilter(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)); @@ -611,6 +612,7 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba Log.i("a", "onDestroy"); // STATIC super.onDestroy(); try { + unregisterReceiver(notificationReceiver); unregisterReceiver(smsReceiver); } catch(IllegalArgumentException e) { Log.i("ppp", Arrays.toString(e.getStackTrace()));