Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class USSDService extends AccessibilityService {
- public static String TAG = "USSDService";
- public String responsee="";
- @Override
- public void onAccessibilityEvent(AccessibilityEvent event) {
- Log.d(TAG, "onAccessibilityEvent");
- String text = event.getText().toString();
- if (event.getClassName().equals("android.app.AlertDialog")) {
- performGlobalAction(GLOBAL_ACTION_BACK);
- Log.d(TAG, text);
- Intent intent = new Intent("message");
- intent.putExtra("value", text);
- Toast.makeText (this,text,Toast.LENGTH_LONG).show();
- this.sendBroadcast(intent);// write a broad cast receiver and call sendbroadcast() from here, if you want to parse the message for balance, date
- }
- }
- @Override
- public void onInterrupt() {
- }
- @Override
- protected void onServiceConnected() {
- super.onServiceConnected();
- Log.d(TAG, "onServiceConnected");
- AccessibilityServiceInfo info = new AccessibilityServiceInfo();
- info.flags = AccessibilityServiceInfo.DEFAULT;
- info.packageNames = new String[]{"com.android.phone"};
- info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
- info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
- setServiceInfo(info);
- }}
- public class MainActivity extends AppCompatActivity {
- private BroadcastReceiver bReceiver = new BroadcastReceiver(){
- @Override
- public void onReceive(Context context, Intent intent) {
- //put here whaterver you want your activity to do with the intent received
- Log.i("onReceive",intent.getStringExtra("value") );
- }
- };
- protected void onResume(){
- super.onResume();
- Log.i("onResume", "22222");
- LocalBroadcastManager.getInstance(this).registerReceiver(bReceiver, new IntentFilter("message"));
- }
- protected void onPause (){
- super.onPause();
- Log.i("onPause", "11111");
- LocalBroadcastManager.getInstance(this).unregisterReceiver(bReceiver);
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement