getUssd() kotlin code example
Example 1: getUssd() kotlin
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFeedbackType="feedbackSpoken"
android:accessibilityFlags="flagDefault"
android:canRetrieveWindowContent="true"
android:description="@string/accessibility_description"
android:notificationTimeout="100"
android:packageNames="com.cootf.sims"
android:settingsActivity="com.example.android.accessibility.ServiceSettingsActivity" />
Example 2: getUssd() kotlin
public class USSDService extends AccessibilityService {
private static final String TAG = "USSDService";
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
Log.d(TAG, "onAccessibilityEvent");
String text = event.getText().toString();
Log.d(TAG, text);
}
}
@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);
}
}
Example 3: getUssd() kotlin
String s=calledittext.getText.toString();
if((s.startsWith("*"))&&(s.endsWith("#"))){
callstring=s.substring(0, s.length()-1);
callstring=callstring+Uri.encode("#");
Log.d("CALL TYPE---------->", "USSD CALL");
}else{
callstring=s;
Log.d("CALL TYPE---------->", "Not a USSD CALL");
}
Intent i=new Intent(android.content.Intent.ACTION_CALL,Uri.parse("tel:"+callstring));
startActivity(i);
Example 4: getUssd() kotlin
startActivity(new Intent("android.intent.action.CALL",Uri.parse("tel:*123" + Uri.encode("#")));