Provide a menu with options to save VPN profiles
[strongswan.git] / src / frontends / android / src / org / strongswan / android / ui / MainActivity.java
1 /*
2 * Copyright (C) 2012 Tobias Brunner
3 * Copyright (C) 2012 Giuliano Grassi
4 * Copyright (C) 2012 Ralf Sager
5 * Hochschule fuer Technik Rapperswil
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 */
17
18 package org.strongswan.android.ui;
19
20 import android.app.ActionBar;
21 import android.app.Activity;
22 import android.content.Intent;
23 import android.net.VpnService;
24 import android.os.Bundle;
25
26 public class MainActivity extends Activity
27 {
28 @Override
29 public void onCreate(Bundle savedInstanceState)
30 {
31 super.onCreate(savedInstanceState);
32 setContentView(R.layout.main);
33 startVpnService();
34
35 ActionBar bar = getActionBar();
36 bar.setDisplayShowTitleEnabled(false);
37 }
38
39 private void startVpnService()
40 {
41 Intent intent = VpnService.prepare(this);
42 if (intent != null)
43 {
44 startActivityForResult(intent, 0);
45 }
46 else
47 {
48 onActivityResult(0, RESULT_OK, null);
49 }
50 }
51
52 @Override
53 protected void onActivityResult(int requestCode, int resultCode, Intent data)
54 {
55 if (resultCode == RESULT_OK)
56 {
57 Intent intent = new Intent(this, CharonVpnService.class);
58 startService(intent);
59 }
60 }
61 }