Fake call in Android

Hi all,

I want to develop a fake call application in android. After clicking on the button I should receive a fake call for a certain period of time. Is there any way to do this .. any hints or sample code ...? Please let me know. Thanks in advance.

+3
source share
2 answers

Android is open source. Use it!

git call_card.xml CallCard.java, . java , ( , , , ) Android .

+8

:

Intent intent = new Intent(this, FakeCallReciever.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 1222222, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

if (mTimer.getText().toString().trim().equalsIgnoreCase("5 sec")) {
    int i = 5;
    alarmManager.set(AlarmManager.RTC_WAKEUP,System.currentTimeMillis() + (i * 1000), pendingIntent);
    Toast.makeText(this, "Fake call scheduled after " + i + " sec",Toast.LENGTH_LONG).show();
}
else if (mTimer.getText().toString().trim().equalsIgnoreCase("10 sec")) {
    int i = 10;
    alarmManager.set(AlarmManager.RTC_WAKEUP,System.currentTimeMillis() + (i * 1000), pendingIntent);
    Toast.makeText(this, "Fake call scheduled after " + i + " sec",Toast.LENGTH_LONG).show();
}

FakeCallReciever.class:

public class FakeCallReciever extends BroadcastReceiver {

private PowerManager.WakeLock mWakelock;
@SuppressWarnings("deprecation")
private KeyguardManager.KeyguardLock mLock;
private static ContentResolver sResolver;

/**
 * onReceive for Reciever
 */

@SuppressWarnings("deprecation")
@Override
public void onReceive(Context paramContext, Intent intent) {

    this.mWakelock = ((PowerManager) paramContext.getSystemService("power"))
            .newWakeLock(805306394/* | PowerManager.ON_AFTER_RELEASE */,
                    "wakelock");
    this.mWakelock.acquire();
    this.mLock = ((KeyguardManager) paramContext
            .getSystemService("keyguard")).newKeyguardLock("");
    this.mLock.disableKeyguard();



    if (Constants.LOG)
        Log.d("FAkceREciever Call", "================>");

    setLockPatternEnabled(true);

    sResolver = paramContext.getContentResolver();

    Intent startMain = new Intent();
    startMain = new Intent(paramContext, InComingCall.class);
    startMain.setAction("com.example.fakecall.MyService");
    startMain.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    paramContext.startActivity(startMain);
}

/**
 * used for to enable lock in all patterns
 * 
 * @param enabled
 */
@SuppressWarnings("deprecation")
public static void setLockPatternEnabled(boolean enabled) {
    setBoolean(android.provider.Settings.System.LOCK_PATTERN_ENABLED,
            enabled);
}

private static void setBoolean(String systemSettingKey, boolean enabled) {
    android.provider.Settings.System.putInt(sResolver, systemSettingKey,
            enabled ? 1 : 0);
}

}

================== InComingCall.class:

, .

.

+1

Source: https://habr.com/ru/post/1764851/


All Articles