Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fake call in android

Tags:

android

HI all,

I want to develop an fake call application in android. After clicking on button i have to receive a fake call with in a given time period. Is there any way to do this.. any clues or sample code...? Please let me know..Thanks in advance.

like image 354
Sri Sri Avatar asked Feb 27 '23 06:02

Sri Sri


2 Answers

Android is open source. Use it!

In the Phone app on the git repository you can find call_card.xml and CallCard.java, which are used to display the incoming call screen. Especially the java file is quite long and complex, but the layout (combined, of course, with the resources it references) should give you a fairly accurate copy of the default Android call screen.

like image 98
benvd Avatar answered Mar 07 '23 00:03

benvd


Button click event class:

Set the alarm manager to intent

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:

Take incoming call activity to show dummy fake call screen.

Its is working to me .

like image 42
madhu kotagiri Avatar answered Mar 07 '23 00:03

madhu kotagiri