6

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.

Sri Sri
  • 3,107
  • 7
  • 34
  • 37
  • @Bobby..thanks for ur idea..Please give me idea how to display fake incoming call screen with accept and reject options..or any sample code..thanks for ur help in advance. – Sri Sri Sep 15 '10 at 11:02
  • I've no idea, I don't do Android-Programming...just create an application and style it that way, that it looks like the Incoming-Call screen. If you've no idea how to do that...you might wanna dig up some tutorials or good books about programming in Android. – Bobby Sep 16 '10 at 12:12
  • nice, it's sound like Fake Call app on Play Store, http://oopsreview.com/create-fake-incoming-phone-call-android/ – yussan Jan 24 '17 at 09:29

2 Answers2

8

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.

Tim
  • 41,901
  • 18
  • 127
  • 145
benvd
  • 5,776
  • 5
  • 39
  • 59
  • 1
    Google has moved the Android source. The Phone app's source can be found here nowadays: https://android.googlesource.com/platform/packages/apps/Phone.git – benvd Apr 02 '16 at 09:26
2

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 .

Konrad Lindenbach
  • 4,911
  • 1
  • 26
  • 28
madhu kotagiri
  • 381
  • 3
  • 14