How to bring Home Screen when an incoming call is received ?

Quickly share your Android Code Snippets here...

How to bring Home Screen when an incoming call is received ?

Postby apurva.giri » Tue Aug 31, 2010 11:57 am

Here's the code i've written (quite simple)....

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="giri.apurva.callintercept"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">

<receiver android:name="CallIntercept"/>
<intent-filter>
<action android:name="android.intent.action.ANSWER" />
</intent-filter>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
</manifest>


CallIntercept.java

package giri.apurva.callintercept;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class CallIntercept extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals ("android.intent.action.ANSWER")) {
// TODO Auto-generated method stub
context.startActivity(new Intent(context, CallInterceptActivity.class));
}}}



CallInterceptActivity.java

package giri.apurva.callintercept;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class CallInterceptActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Intent intent = new Intent("android.intent.category.HOME");
startActivity(intent);
}}


Tried altering few codes, nothing worked... is it even possible ???
I just want to bring the Home Screen & turn off the backlight as soon as the call is accepted...
apurva.giri
Freshman
Freshman
 
Posts: 9
Joined: Thu Aug 19, 2010 12:08 pm

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 3 guests