Issue
On phones I need Activity C
's parent to be Activity B
and on tablets I need Activity C
's parent to be Activity A
. However, I can't set a string resource for the parentActivityName
. Is there a way to do it via XML? Thanks!
<activity
android:name="com.example.app.ActivityC"
<!-- @string resource not accepted here -->
android:parentActivityName="com.example.app.ActivityB">
</activity>
Solution
As far as I know, there's no way. You might do it with your activity itself though. Create a new activity to handle starts on different devices
public class ActivityD {
protected void onCreate (Bundle savedInstanceState) {
boolean isTablet = false || true; // get configuration
Class<?> activity = isTablet ? ActivityB.class : ActivityA.class;
startActivity(new Intent(this, activity));
finish();
}
}
and define it as parent instead
<activity
android:name="com.example.app.ActivityC"
android:parentActivityName="com.example.app.ActivityD">
</activity>
It's not completely XML, but the best I could think about.
Answered By - tynn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.