Android Training/Starting Another Activity/en: Unterschied zwischen den Versionen

FuzzyBot (Diskussion | Beiträge)
Neue Version von externer Quelle importiert
FuzzyBot (Diskussion | Beiträge)
Neue Version von externer Quelle importiert
 
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt)
Zeile 68: Zeile 68:
</syntaxhighlight>
</syntaxhighlight>
#: For the next activity to query the extra data, you should define the key for your intent's extra using a public constant. It's generally a good practice to define keys for intent extras using your app's package name as a prefix. This ensures the keys are unique, in case your app interacts with other apps.
#: For the next activity to query the extra data, you should define the key for your intent's extra using a public constant. It's generally a good practice to define keys for intent extras using your app's package name as a prefix. This ensures the keys are unique, in case your app interacts with other apps.
# In the <code>sendMessage()</code> method, to finish the intent, call the <code>startActivity()</code> method, passing it the<code>Intent</code> object created in step 1.
# In the <code>sendMessage()</code> method, to finish the intent, call the <code>startActivity()</code> method, passing it the <code>Intent</code> object created in step 1.


With this new code, the complete <code>sendMessage()</code> method that's invoked by the Send button now looks like this:
With this new code, the complete <code>sendMessage()</code> method that's invoked by the Send button now looks like this:
Zeile 145: Zeile 145:
}
}
</syntaxhighlight>
</syntaxhighlight>
#: '''Note:''' If you are using an IDE other than Android Studio, your project does not contain the<code>activity_display_message</code> layout that's requested by <code>[http://developer.android.com/reference/android/app/Activity.html#setContentView(android.view.View) setContentView()]</code>. That's OK because you will update this method later and won't be using that layout.
#: '''Note:''' If you are using an IDE other than Android Studio, your project does not contain the <code>activity_display_message</code> layout that's requested by <code>[http://developer.android.com/reference/android/app/Activity.html#setContentView(android.view.View) setContentView()]</code>. That's OK because you will update this method later and won't be using that layout.
# To your <code>strings.xml</code> file, add the new activity's title as follows:
# To your <code>strings.xml</code> file, add the new activity's title as follows:
#: <syntaxhighlight lang="xml">
#: <syntaxhighlight lang="xml">