How to handle Intents in Android app when you have Login Activity -
i looking advice when comes handling flows between activities. let's have 2 activities - loginactivity , mainactivity:
<activity android:name=".loginactivity" android:configchanges="keyboardhidden|orientation" android:label="@string/app_name" android:launchmode="singletop" android:screenorientation="portrait"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".mainactivity" android:configchanges="keyboardhidden|orientation" android:label="@string/app_name" android:launchmode="singletop" android:screenorientation="portrait" />
now, when application starts, start loginactivity, , if login successful show mainactivity.
now, problems start when want handle types of intents. let's want add custom schema app:
<intent-filter> <data android:scheme="customschema" /> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.browsable" /> <category android:name="android.intent.category.default" /> </intent-filter>
to activity add this? ideally love add mainactivity , handle in onnewintent method, possible app not started , in case, first need run loginactivity. on other hand if add loginactivity, need way pass intent mainactivity once user logs in. or if app started need switch focus loginactivity mainactivity , pass intent data immediately.
i believe problem must've been solved , rather follow best practice rather try invent own solution - why looking advice.
forget said initially, thinking of broadcast receivers.
use solution commonsware instead:
Comments
Post a Comment