Added android.net.VpnService wrapper around charon (loaded via JNI).
[strongswan.git] / src / frontends / android / src / org / strongswan / android / strongSwanActivity.java
1 package org.strongswan.android;
2
3 import android.app.Activity;
4 import android.content.Intent;
5 import android.net.VpnService;
6 import android.os.Bundle;
7
8 public class strongSwanActivity extends Activity {
9 @Override
10 public void onCreate(Bundle savedInstanceState) {
11 super.onCreate(savedInstanceState);
12 setContentView(R.layout.main);
13 startVpnService();
14 }
15
16 private void startVpnService() {
17 Intent intent = VpnService.prepare(this);
18 if (intent != null) {
19 startActivityForResult(intent, 0);
20 } else {
21 onActivityResult(0, RESULT_OK, null);
22 }
23 }
24
25 @Override
26 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
27 if (resultCode == RESULT_OK) {
28 Intent intent = new Intent(this, CharonVpnService.class);
29 startService(intent);
30 }
31 }
32 }