views:

306

answers:

0

Following on from my Question Here i have found what the problem is but cant seem to fix it.

What appears to be happening is that my Application launches, the user can then press a button to start a background service and the Activity disappears.

The user then makes a call and from here my applications dialog screen appears. In the intent to start my dialog screen I am passing in the application context.

So would the dialer be becoming the context that the dialog screen is fired from and thats why the dialer icon is appearing in recently used apps and restarts my dialog?

Here is the code used to start my dialog:

 public void startDialog(Context aContext, String phoneNumber, String pName){

 //starts in call dialog
     final Intent myIntent = new Intent(aContext, CallDialogActivity.class);
     myIntent.putExtra("NAME", pName);
     myIntent.putExtra("NUMBER", phoneNumber);
     myIntent.setFlags(myIntent.FLAG_ACTIVITY_NEW_TASK);
     context.startActivity(myIntent);

}

So the dialer app is becoming the context some how I reckon?

Is there anyway to start the dialog activity without needing to use the context or anyway to make sure its my application that is the context and not the dialer?

EDIT:

Just to add, testing on 1.6 Vanilla Android works fine but testing on HTC Hero with 1.5 Android + HTC's Sense overlay causes the problem

I have narrowed it to the fact that setResultData blocks the call bust doesn't actually stop it, on the Hero the dialer is still waiting for the call to take place.

Code:

callRcv = new BroadcastReceiver(){
        public void onReceive(Context contextfail, Intent intent) {


            String action = intent.getAction();
            Log.d("CALL MONITOR", "Action recieved = : " + contextfail);
            if (Intent.ACTION_NEW_OUTGOING_CALL.equals(action)) {

                if(wifiManager.getCurrentWifiState() == WIFI_CONNECTED){
                String number = getResultData();
                setResultData(null);
                //Log.d("CALL MONITOR", "Outgoing call logged over wifi");
               cla.addCallToLog(contextfail, number, DIALLED_CALL);
                String pName = getContactDetails(context, number);
                makeCallDialog(contextfail, number, pName);
                }
                else{
                    Log.d("CALL MONITOR", "Outgoing call logged over GSM");

                }  
            }
        } 
     };
     context.registerReceiver(callRcv, new IntentFilter(Intent.ACTION_NEW_OUTGOING_CALL));

So the call is blocked but still needs to be dealt with in some way? Can anyone reccomend a work around?