我正在使用Intent intent = new Intent(Intent.ACTION_CALL);
從我的應用程序撥打電話。如何停止一次intent.ACTION_CALL啓動?
有沒有什麼辦法在一段時間後終止通話?或者在ACTION_CALL啓動之前設置一個定時器?
我使用下面的代碼從Prasanta的博客,但由於某種原因context
正在獲取下面的錯誤。有什麼建議麼?
不能得到解決
import java.lang.reflect.Method;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import com.android.internal.telephony.ITelephony;
public class AnswerActivity extends Activity {
private static final String TAG = null;
/** Called when the activity is first created. */
private ITelephony telephonyService;
TelephonyManager telephonyManager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);{
try {
// Java reflection to gain access to TelephonyManager's
// ITelephony getter
Log.v(TAG, "Get getTeleService...");
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
com.android.internal.telephony.ITelephony telephonyService =
(ITelephony) m.invoke(tm);
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG,
"FATAL ERROR: could not connect to telephony subsystem");
Log.e(TAG, "Exception object: " + e);
}
}
}
}
看到這篇文章http://stackoverflow.com/questions/599443/android-how-to-hang-up-outgoing-call –
@MoshErsan謝謝,我已閱讀該帖子,但我無法執行。 conext無法解析錯誤 – Parksie
在這裏寫一些代碼看看 –