mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
how-tos made with markdown snippet injector
This commit is contained in:
@@ -5,32 +5,23 @@ import commonTests = require("./application-tests-common");
|
||||
|
||||
global.moduleMerge(commonTests, exports);
|
||||
|
||||
// <snippet module="application" title="application">
|
||||
// ### Using the Android-specific implementation
|
||||
// Accessing the Android-specific object instance (will be undefined if running on iOS)
|
||||
// ``` JavaScript
|
||||
// >> application-app-android
|
||||
var androidApp = app.android;
|
||||
// ```
|
||||
// </snippet>
|
||||
// <snippet module="application" title="application">
|
||||
// ### Using the Android Application context
|
||||
// ``` JavaScript
|
||||
// << application-app-android
|
||||
|
||||
// >> application-app-android-context
|
||||
var context = app.android.context;
|
||||
//// get the Files (Documents) folder (directory)
|
||||
var dir = context.getFilesDir();
|
||||
// ```
|
||||
// </snippet>
|
||||
// <snippet module="application" title="application">
|
||||
// ### Tracking the current Activity
|
||||
// ``` JavaScript
|
||||
// << application-app-android-context
|
||||
|
||||
// >> application-app-android-current
|
||||
if (androidApp.foregroundActivity === androidApp.startActivity) {
|
||||
////console.log("We are currently in the main (start) activity of the application");
|
||||
}
|
||||
// ```
|
||||
// </snippet>
|
||||
// <snippet module="application" title="application">
|
||||
// ### Registering a Broadcast Receiver (Android)
|
||||
// ``` JavaScript
|
||||
// << application-app-android-current
|
||||
|
||||
// >> application-app-android-broadcast
|
||||
//// Register the broadcast receiver
|
||||
if (app.android) {
|
||||
app.android.registerBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED,
|
||||
@@ -45,8 +36,7 @@ if (app.android) {
|
||||
if (app.android) {
|
||||
app.android.unregisterBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED);
|
||||
}
|
||||
// ```
|
||||
// </snippet>
|
||||
// << application-app-android-broadcast
|
||||
|
||||
export var testAndroidApplicationInitialized = function () {
|
||||
TKUnit.assert(app.android, "Android application not initialized.");
|
||||
|
||||
Reference in New Issue
Block a user