Android Notes
Android Notes
Android Notes
to send
push notification to a android device
try {
String androidFcmKey="XXXXXXXXXXXX";
String androidFcmUrl="https://fcm.googleapis.com/fcm/send";
msg.put("title", "Title");
msg.put("body", "Message");
msg.put("notificationType", "Test");
json.put("data", msg);
json.put("to", deviceToken);
sender id :A unique numerical value created when you configure your API project.
The sender ID is used in the registration process to identify an app server that is
permitted to send messages to the client app.
Server key A key saved on the app server that gives the app server authorized
access to Google services. In HTTP, the server key is included in the header of
POST requests that send messages.
Application id : The client app that is registering to receive messages. How this
is implemented is platform-dependent:
AVD manager --- android virtual device manager -- nexus5 to set default device
to solve this just run exe from the path of android sdk path having intel hardware
accelator
intelhaxm-android (2 gb)
manifest folder -- main launcher having entry of all activities will have action
tag with acitivty package name
setOnClickListener(){
new View.OnClickListener(){
public void onClick(View v){
AlertDialog.Builder
DialogInterface
}
}
setContentView(R.layout.activity_main)
ListView
ArrayAdapter
seekbar -- progress bar
android gestures..
Google Cloud Messaging (GCM) is a service that lets developers send short message
data to their users on Android devices,
Dalvik Virtual Machine which is a kind of Java Virtual Machine specially designed
and optimized for Android.
Android framework includes the following key services -
Content Providers - Allows applications to publish and share data with other
applications.
Activities : They dictate the UI and handle the user interaction to the smart phone
screen.
Services: They handle background processing associated with an application.
Broadcast Receivers: They handle communication between Android OS and applications.
Content Providers: They handle data and database management issues.
Activity performs actions on the screen. For example, an email application might
have one activity that shows a list of new emails, another activity to compose an
email, and another activity for reading emails.
select the form factors your application runs on, here need to specify Minimum SDK,
in our tutorial, I have declared as API23: Android 6.0(Mashmallow) -- target
android devices...
MainActivity.java source file having an activity class that runs when your app is
launched using the app icon.
layout/
XML files that define a user interface layout. They are saved in res/layout/ and
accessed from the R.layout class.
defined content provider URI address which will be used to access the content...
content://contacts/people/5
SQLite database
Finally register your Content Provider in your activity file using <provider> tag.
values.put(StudentsProvider.GRADE,
((EditText)findViewById(R.id.editText3)).getText().toString());
Toast.makeText(getBaseContext(),
uri.toString(), Toast.LENGTH_LONG).show();
on retrieve
String URL = "content://com.example.MyApplication.StudentsProvider";
Uri students = Uri.parse(URL);
Cursor c = managedQuery(students, null, null, null, "name");
if (c.moveToFirst()) {
do{
Toast.makeText(this,
c.getString(c.getColumnIndex(StudentsProvider._ID)) +
", " + c.getString(c.getColumnIndex( StudentsProvider.NAME)) +
", " + c.getString(c.getColumnIndex( StudentsProvider.GRADE)),
Toast.LENGTH_SHORT).show();
} while (c.moveToNext());
}
}
A fragment has its own layout and its own behaviour with its own life cycle
callbacks.
create fragments by extending Fragment class and You can insert a fragment into
your activity layout by declaring the fragment in the activity's layout file, as a
<fragment> element.
fragment give more flexibiilty. divide device screen and control different parts
separately.
broadcastIntent to send it to any interested BroadcastReceiver components
an Intent object, is a passive data structure holding an abstract description of an
operation to be performed.
let's assume that you have an Activity that needs to launch an email client and
sends an email using your Android device. For this purpose, your Activity would
send an ACTION_SEND along with appropriate chooser, to the Android Intent Resolver
assume that you have an Activity that needs to open URL in a web browser on your
Android device. For this purpose, your Activity will send
ACTION_WEB_SEARCH Intent to the Android Intent Resolver to open given URL in the
web browser.
String q = "tutorialspoint"
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH );
intent.putExtra(SearchManager.QUERY, q);
startActivity(intent);
ACTION_GTALK_SERVICE_DISCONNECTED
View is the base class for widgets, which are used to create interactive UI
components like buttons, text fields, etc.
you can declare your layout using simple XML file main_layout.xml which is located
in the res/layout folder of your project.
A View is an object that draws something on the screen that the user can interact
Toast class provides a handy way to show users alerts but problem is that these
alerts are not persistent
flashes for few seconds...
callback method is called when location service is connected to the location client
successfully. You will use connect() method to connect to the location client
or
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "default content");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);