calllog - Android showing device Call-Log screen after call gets finished/End -
possible duplicate:
how make phone call in android , come activity when call done?
i trying make/initiate call using (uri intent) following code in android on nexus-s:
intent callintent = new intent(intent.action_call); callintent.setdata(uri.parse("tel:"+phoneno)); startactivity(callintent);
on nexus-s after call gets finished showing device call logs screen instead of going activity.
is there way device native call logs screen should not appear after call ends, , return activity or other activity show?
yesterday made simple app , makes call , after ending call come base activity
here code may you
makephonecallactivity.java
package com.rdc; import android.app.activity; import android.content.context; import android.content.intent; import android.net.uri; import android.os.bundle; import android.telephony.phonestatelistener; import android.telephony.telephonymanager; import android.util.log; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; public class makephonecallactivity extends activity { private button button; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); button = (button) findviewbyid(r.id.buttoncall); // add button listener button.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { intent callintent = new intent(intent.action_call); callintent.setdata(uri.parse("tel:9741817902")); startactivity(callintent); } }); // add phonestatelistener phonecalllistener phonelistener = new phonecalllistener(); telephonymanager telephonymanager = (telephonymanager) .getsystemservice(context.telephony_service); telephonymanager.listen(phonelistener, phonestatelistener.listen_call_state); } //monitor phone call activities private class phonecalllistener extends phonestatelistener { private boolean isphonecalling = false; string tag = "debug"; @override public void oncallstatechanged(int state, string incomingnumber) { if (telephonymanager.call_state_ringing == state) { // phone ringing log.i(tag, "ringing, number: " + incomingnumber); } if (telephonymanager.call_state_offhook == state) { // active log.i(tag, "offhook"); isphonecalling = true; } if (telephonymanager.call_state_idle == state) { // run when class initial , phone call ended, // need detect flag call_state_offhook log.i(tag, "idle"); if (isphonecalling) { log.i(tag, "restart app"); // restart app intent = getbasecontext().getpackagemanager() .getlaunchintentforpackage( getbasecontext().getpackagename()); i.addflags(intent.flag_activity_clear_top); startactivity(i); isphonecalling = false; } } } } }
main.xml
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <button android:id="@+id/buttoncall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="make call" /> </linearlayout>
and manifest is
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.rdc" android:versioncode="1" android:versionname="1.0"> <uses-sdk android:minsdkversion="8" /> <uses-permission android:name="android.permission.call_phone" /> <uses-permission android:name="android.permission.read_phone_state" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".makephonecallactivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> </manifest>
let me know if still trouble there.
Comments
Post a Comment