Note that there are some explanatory texts on larger screens.

plurals
  1. POStart activity in a try/catch bloc
    text
    copied!<p>I just want to know how to launch an Activity in a try/catch bloc, i made this </p> <pre><code> public void onReceive(Context context, Intent intent) { SipAudioCall incomingCall = null; try { Intent monIntent = new Intent(this,dialog.class); startActivity(monIntent); SipAudioCall.Listener listener = new SipAudioCall.Listener() { @Override public void onRinging(SipAudioCall call, SipProfile caller) { </code></pre> <p>But i have errors:</p> <pre><code>constructor Intent(IncomingCallReceiver, Class&lt;dialog&gt;) is not defined Method startActivity(Intent) is undefined for the type IncomingCallReceiver </code></pre> <p>I want to show an alertdialog when having a call. How can i solve this problem?</p> <p>Thank you very much. Whole class:</p> <pre><code>public class IncomingCallReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { SipAudioCall incomingCall = null; try { SipAudioCall.Listener listener = new SipAudioCall.Listener() { @Override public void onRinging(SipAudioCall call, SipProfile caller) { try { call.answerCall(30); } catch (Exception e) { e.printStackTrace(); } } }; SIPCommunicator wtActivity = (SIPCommunicator) context; incomingCall = wtActivity.manager.takeAudioCall(intent, listener); incomingCall.answerCall(30); incomingCall.startAudio(); incomingCall.setSpeakerMode(true); if(incomingCall.isMuted()) { incomingCall.toggleMute(); } wtActivity.call = incomingCall; wtActivity.updateStatus(incomingCall); } catch (Exception e) { if (incomingCall != null) { incomingCall.close(); } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload