2 TutorialHelloWorldActivity.java
3 Copyright (C) 2010 Belledonne Communications, Grenoble, France
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package org.linphone.core.tutorials;
21 import org.linphone.R;
22 import org.linphone.core.LinphoneCoreException;
24 import android.app.Activity;
25 import android.os.Bundle;
26 import android.os.Handler;
27 import android.view.View;
28 import android.widget.Button;
29 import android.widget.TextView;
32 * Activity for displaying and starting the HelloWorld example on Android phone.
34 * @author Guillaume Beraudo
37 public class TutorialHelloWorldActivity extends Activity {
39 private static final String defaultSipAddress = "sip:";
40 private TextView sipAddressWidget;
41 private TutorialHelloWorld tutorial;
42 private Handler mHandler = new Handler() ;
43 private Button buttonCall;
46 protected void onCreate(Bundle savedInstanceState) {
47 super.onCreate(savedInstanceState);
48 setContentView(R.layout.hello_world);
49 sipAddressWidget = (TextView) findViewById(R.id.AddressId);
50 sipAddressWidget.setText(defaultSipAddress);
52 // Output text to the outputText widget
53 final TextView outputText = (TextView) findViewById(R.id.OutputText);
54 final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText);
57 // Create HelloWorld object
58 tutorial = new TutorialHelloWorld(notifier);
62 // Assign call action to call button
63 buttonCall = (Button) findViewById(R.id.CallButton);
64 buttonCall.setOnClickListener(new View.OnClickListener() {
65 public void onClick(View v) {
66 TutorialLaunchingThread thread = new TutorialLaunchingThread();
67 buttonCall.setEnabled(false);
72 // Assign stop action to stop button
73 Button buttonStop = (Button) findViewById(R.id.ButtonStop);
74 buttonStop.setOnClickListener(new View.OnClickListener() {
75 public void onClick(View v) {
76 tutorial.stopMainLoop();
82 private class TutorialLaunchingThread extends Thread {
87 tutorial.launchTutorial(sipAddressWidget.getText().toString());
88 mHandler.post(new Runnable() {
90 buttonCall.setEnabled(true);
93 } catch (LinphoneCoreException e) {