【Android源码 栏目提醒】:本文主要为网学会员提供“[SipDemo工程][android源码][WalkieTalkieActivity java] - 开发文档”,希望对需要[SipDemo工程][android源码][WalkieTalkieActivity java] - 开发文档网友有所帮助,学习一下!
/ Copyright C 2010 The Android Open Source Project Licensed under the Apache License Version 2.0 the License you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing software distributed under the License is distributed on an AS IS BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied. See the License for the specific language governing permissions and limitations under the License. / package com.example.android.sip import android.app.Activity import android.app.AlertDialog import android.app.Dialog import android.app.PendingIntent import android.content.DialogInterface import android.content.Intent import android.content.IntentFilter import android.content.SharedPreferences import android.os.Bundle import android.preference.PreferenceManager import android.util.Log import android.view. import android.net.sip. import android.widget.EditText import android.widget.TextView import android.widget.ToggleButton import java.text.ParseException / Handles all calling receiving calls and UI interaction in the WalkieTalkie app. / public class WalkieTalkieActivity extends Activity implements View.OnTouchListener public String sipAddress null public SipManager manager null public SipProfile me null public SipAudioCall call null public IncomingCallReceiver callReceiver private static final int CALL_ADDRESS 1 private static final int SET_AUTH_INFO 2 private static final int UPDATE_SETTINGS_DIALOG 3 private static final int HANG_UP 4 Override public void onCreateBundle savedInstanceState super.onCreatesavedInstanceState setContentViewR.layout.walkietalkie ToggleButton pushToTalkButton ToggleButton findViewByIdR.id.pushToTalk pushToTalkButton.setOnTouchListenerthis // Set up the intent filter. This will be used to fire an // IncomingCallReceiver when someone calls the SIP address used by this // application. IntentFilter filter new IntentFilter filter.addActionandroid.SipDemo.INCOMING_CALL callReceiver new IncomingCallReceiver this.registerReceivercallReceiver filter // Push to talk can be a serious pain when the screen keeps turning off. // Lets prevent that. getWindow.addFlagsWindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON initializeManager Override public void onStart super.onStart // When we get back from the preference setting Activity assume // settings have changed and re-login with new auth info. initializeManager Override public void onDestroy super.onDestroy if call null call.close closeLocalProfile if callReceiver null this.unregisterReceivercallReceiver public void initializeManager ifmanager null manager SipManager.newInstancethis initializeLocalProfile / Logs you into your SIP provider registering this device as the location to send SIP calls to for your SIP address. / public void initializeLocalProfile if manager null return if me null closeLocalProfile SharedPreferences prefs PreferenceMana