Sri Sri
Sri Sri

Reputation: 3109

Fake call in 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.

Upvotes: 6

Views: 16320

Answers (2)

benvd
benvd

Reputation: 5784

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.

Upvotes: 8

madhu kotagiri
madhu kotagiri

Reputation: 381

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 .

Upvotes: 2

Related Questions