2013-12-20 39 views
2

我希望在接到來電時將我的應用程序置於電話呼叫答覆屏幕的前方。我在接到電話後做了每個編碼部分。但該應用程序並不在前面。它只是打開並保持在電話接聽屏幕下方。
我想把我的應用程序放在這個屏幕的前面。

我不喜歡的東西如下:在接到電話時將應用程序置於前端

Intent i = new Intent(); i.setAction(Intent.ACTION_MAIN); 
i.addCategory(Intent.CATEGORY_LAUNCHER); 
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); 
ComponentName cn = new ComponentName(this, MainActivity.class); 
i.setComponent(cn); 
startActivity(i); 

但沒有改變。

+0

您可以將您的接收器標籤中提到你的清單文件。 –

+0

接收器沒有問題。它的工作正常..當電話收到應用程序啓動。但它沒有來到前臺..這是我面臨的問題.. –

+0

你有沒有提到清單中的接收器的任何**優先**? –

回答

0

優先添加到receiver..this將有助於不是由Android操作系統

<receiver android:name="com.companyname.receivers.InComingCallReceiver" > 
     <intent-filter android:priority="2147483647" > 
      <action android:name="android.intent.action.PHONE_STATE" /> 
     </intent-filter> 
</receiver> 

希望本地來電之前被稱爲這將是有益的

0

您需要實現一個服務來從後臺調用應用程序。

public class LaunchApplication extends Service { 

    String PubNubmessage; 

    public LaunchApplication() { 
     super(); 

    } 

    @Override 
    public void onCreate() { 

     super.onCreate(); 


    } 

    @Override 
    public int onStartCommand(Intent intent, int flags, int startId) { 
     super.onStartCommand(intent, flags, startId); 
     LaunchApplicationWhenReceivedCall(); 

     return START_NOT_STICKY; 
    } 

    private void LaunchApplicationWhenReceivedCall() { 
     Intent intent1 = new Intent(getApplicationContext(), HomeActivity.class); 

     intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK 
       | Intent.FLAG_ACTIVITY_SINGLE_TOP); 
     startActivity(intent1); 
    } 

    @Override 
    public IBinder onBind(Intent intent) { 

     return null; 
    } 

} 

現在開始服務,當您的應用程序檢測到收到呼叫。

+0

抱歉..這不是我正在尋找的正確答案.. –

相關問題