[英]How can I get the Adapter (or actually transfer data to the adapter)that's object is initiated in the other activity from the MainActivity?
[英]How can i get the time of the call initiated?
我正在制作一個 android 應用程序。我會從一個設備呼叫並在另一個設備上接收,但是誰能告訴我如何在呼叫方設備發起呼叫的時間在接收方設備上獲得時間? 因為我想計算撥打電話和接到電話的延遲時間?
當您從一個設備呼叫時,您可以在 api 的幫助下將時間存儲在服務器端,當您接到呼叫時,您可以再次集成 api 以獲取第一個設備呼叫您的時間。
您應該創建一個 BroadcastReceiver:
public class CallReciever extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(
TelephonyManager.EXTRA_STATE_RINGING)) {
// Phone number
String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
// Ringing state
// This code will execute when the phone has an incoming call
} else if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(
TelephonyManager.EXTRA_STATE_IDLE)
|| intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(
TelephonyManager.EXTRA_STATE_OFFHOOK)) {
// This code will execute when the call is answered or disconnected
}
}
}
您應該注冊您的應用程序以在清單中監聽這些意圖:
<receiver android:name=".CallReciever" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
這樣您就可以節省啟動時間和摘機時間。 得到這之間的區別將是你想要的延遲。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.