Reputation: 6699
I have registered my activity to handle the ACTION_DIAL intent but in certain cases I want to basically ignore the intent. In onCreate, I'm checking SharedPreferences for a bool that means user has access to dial, if not then I call finish() and then return; But this still shows a window flashing open and then closed, how can I avoid that?
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean hasDialer = prefs.getBoolean(Preferences.HAS_DIALER, false);
// Check if ACTION_DIAL intent was launched to bring user into the app
String number = getIntent().getDataString();
if (!TextUtils.isEmpty(number))
{
if (hasDialer)
{
launchDialer = true;
}
else
{
finish();
return;
}
}
}
Upvotes: 1
Views: 76
Reputation: 14710
You could register the ACTION_DIAL
in a broadcast receiver (directly in the manifest) or in a service (now this depends on what else are you planning to do) and have the same logic in there. You can start activities from there if you need to.
Upvotes: 3