summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/api/GrantPermissionsActivity.java
blob: 659ec24b0fdae639b23dbe7934cd9ac4ad384c89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package de.blinkt.openvpn.api;

import android.app.Activity;
import android.content.Intent;
import android.net.VpnService;

public class GrantPermissionsActivity extends Activity {
	private static final int VPN_PREPARE = 0;

	@Override
	protected void onStart() {
		super.onStart();
		Intent i= VpnService.prepare(this);
		if(i==null)
			onActivityResult(VPN_PREPARE, RESULT_OK, null);
		else
			startActivityForResult(i, VPN_PREPARE);
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		setResult(resultCode);
		finish();
	}
}