Notizen
Android Advance
Inhalt der Notizen (3)
Seite 1
Connecting adb with your computer on Wifi Network
* You need to connect your phone once with your Computer with USB
$ adb devices (Will list your devices)
List of devices
attached
0070015947d30e4b device
$ adb tcpip 5555 (Open this port no of your phone to communicate with your phone)
$ adb connect 192.168.1.104 (Connect your phone with Ip address)
$ adb devices
List of devices attached
192.168.1.104:5555 device
Command to list out all the packages in your android device
adb shell pm list packages
Monkey Test of your device (Also called the stress test)
adb shell monkey –p
Building and cleaning android project from shell
$ ./gradlew clean build
Android library project
Android library project is basically a standard Android project that doesn’t declare any components that can
be started (Activities, Services, BroadcastReceivers, or ContentProviders) and that won’t
generate an APK when compiled or exported
You can set up a library project from the Android Studio IDE. Simply create a new module and choose Android
Library as the module type. A gradle.build will be generated for the new library project as shown next.
buildscript {
repositories {
maven {
url ‘http://repo1.maven.org/maven2’
}
}
dependencies {
classpath ‘com.android.tools.build:gradle:0.4’
}
}
apply plugin: ‘android-library’
dependencies {
compile files(‘libs/android-support-v4.jar’)
}
android {
compileSdkVersion 17
buildToolsVersion “17.0.0”
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
******* Note that the only difference from the default build file for Android project is the use of the plug-in androidlibrary
instead of android.
Seite 2
** There are four types of components in android (Activity, Services, BroadcastReceivers, and
ContentProviders) are the ones most frequently used. Activities are responsible for the user interface,
Services implement operations running in the background, BroadcastReceivers listen for system
events, and ContentProviders store application data.**
They all come with a base class that you extend and a section in the application manifest XML file that exposes
them to the Android system. There is also a fifth type of component with the name Application that, though
rarely utilized, is useful in some situations
BroadcastReceivers are special components because they are stateless, which means that the
BroadcastReceiver object is valid only during the onReceive() call. Therefore, you can’t keep a
reference to the BroadcastReceiver instance that’s declared in the manifest anywhere in your code.
Also, you can’t add the instance as a listener or callback to an asynchronous operation. Basically, the only
thing you can and should do in the onReceive() method of a BroadcastReceiver is to delegate
the call to another component, either through the Context.startActivity() or the Context.
startService() method
This limitation makes BroadcastReceivers useful for one thing only: listening to system events.
Some BroadcastIntents don’t allow you to register them through the manifest. For
instance, the broadcast defined by Intent.ACTION_BATTERY_CHANGED can be received only from a
BroadcastReceiver registered with Context.registerReceiver()
Every component you define is enabled by default. You can change this by setting
android:enabled=”false”, which will prevent them from receiving Intents. Disabled Activities
won’t show up in the application launcher, Services won’t respond to startService() calls,
BroadcastReceivers won’t listen to BroadcastIntents, and ContentProviders won’t respond to
the ContentResolver. You can change this setting in your code, which is especially efficient if you want to
make sure that parts of your application remain disabled until the user completes certain configuration steps.
I
Sometimes you have a component, usually a Service, that you don’t want to expose to the rest of the
system for security purposes. To do this, you can set the android:exported attribute to false, which will
effectively hide that component from the rest of the system.
* Types of Intent
Explicit
Intents contain information about the package and the name of the component, and these can be delivered
immediately because there can be only one match. This method is generally used for application-internal
communication. Implicit Intent resolution depends on three factors: the action of the Intent, the data URI
and type, and the category. Extras and flags on Intents carry no meaning when it comes to deciding where
they should be delivered.

Seite 3
Informationen
- Beschreibung
- Notiz am Android Advance, erstellt von Sahitya Suman am 22/08/2016.
- Erstellt von
- Sahitya Suman · Aug 2016
- Aktualisiert
- 25 Aug 2016
- Aufrufe
- 0
- Bewertung