如何切換功能取決於父活動我有兩種情況下,我想要在function.my函數之間切換與短信otp驗證有關。如何切換意圖功能取決於活動
案例1.當用戶正在註冊功能正在驗證otp並激活用戶。
case2:當用戶忘記密碼時,他們將生成一個新的otp來重置密碼。
這裏是我的功能代碼
@Override
protected void onHandleIntent(Intent intent) {
// SqLite database handler
db = new SQLiteHandler(getApplicationContext());
// Fetching user details from sqlite
HashMap<String, String> user = db.getUserDetails();
if (intent != null) {
String otp = intent.getStringExtra("otp");
String phone = user.get("phone");
verifyOtp(otp,phone);
}
}
現在我想讓它像
@Override
protected void onHandleIntent(Intent intent) {
// SqLite database handler
db = new SQLiteHandler(getApplicationContext());
// Fetching user details from sqlite
HashMap<String, String> user = db.getUserDetails();
if (intent != null) {
String otp = intent.getStringExtra("otp"); //this coming from sms receiver
//from here i want to switch if parent activity is register activity below function should run
String phone = user.get("phone");
verifyOtp(otp,phone);
// if parent activity if forgot password activity the below function should run
String phone = session.getmobileno();
verifyfpass(otp,phone)
}
}
感謝代碼 –