如果在打開應用程序時權限被吊銷會發生什麼?我已經嘗試過,發現應用程序的進程突然終止。應用程序中的所有內容都僅僅停止了而本地保存Apputil值變爲零,當我關掉許可當應用程序是opened.If人都知道的原因,請給我建議,如何解決這個問題RunTime權限棉花糖Android
// I am extending drawer activity to get the saved card number here
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.activity_reward_yourself,
null, false);
titleTextView.setText(R.string.reward_yourself_title);
frameLayout.addView(contentView, 0);
rewardsSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.rewardsSwipeContainer);
grid = (GridView) findViewById(R.id.gridReward);
tvPointsValue = (TextView) findViewById(R.id.tvPointsValue);
tvFirstText = (TextView) findViewById(R.id.tvFirstText);
rewardsSwipeLayout.setOnRefreshListener(this);
rewardsSwipeLayout.setColorScheme(android.R.color.black,
android.R.color.white, android.R.color.darker_gray,
android.R.color.black);
initialUiSetUp();
program = new Program();
String str= AppUtil.fxs.getCardNumber(); //becomes null when location is off when app is opened
checkPermission(MyActivity.this);
mAccInfo = new Account();
mTask = new GetAccount().execute();
}
代碼在哪裏? – Piyush
每當您調用需要此權限的方法時,您都必須定期檢查權限。這樣,您可以控制在撤銷權限時應該執行的操作,而不是讓應用程序終止。 – Kharda
@Piyush我附上的代碼部分。謝謝你的回覆 – Ramya