android - How to get the key from a calling preference -



android - How to get the key from a calling preference -

this part of preferences.xml. 1 of these preferences phone call same activity, changepwemail, when user click on either 1 of them.

<preferencecategory android:title="security"> <preference android:title="change email" android:summary="option alter email" android:key="pref_security_email"> <intent android:action="android.intent.action.main" android:targetpackage="com.test" android:targetclass="com.test.changepwemail"/> </preference> <preference android:title="change password" android:summary="option alter password" android:key="pref_security_password"> <intent android:action="android.intent.action.main" android:targetpackage="com.test" android:targetclass="com.test.changepwemail"/> </preference> </preferencecategory>

in changepwemail class, how key value (either "pref_security_email" or "pref_security_password") can appropriate action whether email or password alter request? i'll appreciate help. thanks.

<preferencecategory android:title="security"> <preference android:title="change email" android:summary="option alter email" android:key="pref_security_email"> <intent android:action="com.example.action.email" android:targetpackage="com.test" android:targetclass="com.test.changepwemailactivity"/> </preference> <preference android:title="change password" android:summary="option alter password" android:key="pref_security_password"> <intent android:action="com.example.action.password" android:targetpackage="com.test" android:targetclass="com.test.changepwemailactivity"/> </preference> </preferencecategory>

in activity:

if (getintent() != null) if ("com.test.action.email".equals(activtiy.getintent().getaction())) { } else if ("com.test.action.password".equals(activtiy.getintent().getaction())) { } else { }

in manifest:

<activity android:name="com.test.changepwemailactivity" > <intent-filter> <action android:name="com.test.action.email" /> <action android:name="com.test.action.password" /> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity>

google android intents , interactions.

android call preferences preferenceactivity

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -