request VpnService on first startup
This commit is contained in:
parent
f592cb40f5
commit
e73cf265a5
1 changed files with 9 additions and 0 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package net.typeblog.socks;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.VpnService;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
|
|
@ -8,6 +10,13 @@ public class MainActivity extends Activity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Prepare the VPN connection (this will request permission if needed)
|
||||
Intent prepareIntent = VpnService.prepare(this);
|
||||
if (prepareIntent != null) {
|
||||
// Permission not yet granted, start the activity to request it
|
||||
startActivityForResult(prepareIntent, 0);
|
||||
}
|
||||
|
||||
this.getFragmentManager().beginTransaction().replace(android.R.id.content, new ProfileFragment()).commit();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue