Actually it is a render time log. No connection with java code. I also have same log. and i feel its cause by : SupportMapFragment in xml file. When i touch Map, GL render layout and prints this log.
It is inside Map Library. So we can't modify it. but i think sometimes it cause memory overload. and so system calls GC to dump memory.
It's just a warning. So ignore it for now. but it should be fix by Google map library maker.
Android platform includes the SQLite embedded database and provides out of the box support to use it via Android APIs. In this tutorial we shall see how to get started with SQLitedatabase in Android. SQLiteis nothing but a relational database and our SQLskills will help.
How to Use SQLite with Android?
To use SQLitein Android, a java class should be created as a sub class of SQLiteOpenHelper.
This class will act as a database controller which will have the
methods to perform the CRUD operations. This custom java class should
override the methods named onCreate()and .onUpgrade() onCreate() method will be called for the first time when
the Android application is run. First the database instance should be
created using the method like getReadableDatabase() or getWritableDatabase() based on the type of access required. Android supports this method by providing in-built methods. For that, SQLiteQueryBuilder class should be imported.
Lets have three Android Activity for List, Add and Edit operations and ensure that these are declared in manifest file. And then we need to create subclass of SQLiteHelper to manage SQLite database.
+------------+------------+------------------------------+---+--------+--+
| Field Name | Field Type | Sample |
+------------+------------+------------------------------+---+--------+--+
| ID | PRIMARY KEY [Auto Generated] | 1 |
| Name | TEXT | Chintan Khetiya |
| Number | TEXT | 787-806-0124 |
| Email | TEXT | khetiya.chintan@gmail.com |
+------------+------------+------------------------------+---+--------+--+
Create or Setup Database:
DatabaseHandler.java is going to be our custom java class that will
manage the SQLite database. We should extend SQLiteOpenHelper and
override the essential methods. The constructor is the hook that will be
used to setup the database. While running the Android application, the
database will be created for the first time.
SQLiteOpenHelper provides callback methods and we should override it to get our job done. Those callback methods that we can override are onCreate(), onUpgrade(), onOpen() and onDowngrade(). And onCreate() and onUpgrade() are abstract methods and must be overridden. onCreate(SQLiteDatabase database) – is the method which
is called first time when the database is created and we need to use
this method to create the tables and populate it as per the need.
db.execSQL("DROP TABLE IF EXISTS "+ TABLE_CONTACTS);
// Create tables again
onCreate(db);
}
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "(" +
KEY_ID + " INTEGER PRIMARY KEY," + KEY_NAME + " TEXT," +
KEY_PH_NO + " TEXT," + KEY_EMAIL + " TEXT" + ")";
db.execSQL(CREATE_CONTACTS_TABLE);
}
onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)– is the method called when upgrade is done.We can drop the database and reset
if required.
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_CONTACTS);
// Create tables again
onCreate(db);
}
How it looks after all task ?
Note:The Contact details are fake or random
Do some Task :
We shall have other user defined methods to handle the sql aobve
operations. The <code>Contact table </code> will be created
when the onCreate() method is invoked while installing the application. For performing operations like insert, update, the SQLiteDatabase instance should be created using the methods like getReadableDatabase() or getWritableDatabase(). ContentValues() are used to pass values to the query.
Which is the major issue or difficulty developer face during development
? just ask your self and you will find that answer is Utils function
which we are using in daily basis. We are doing coding whole day most of
the conman things are repeated in all project or module , only some
part of the unique code , view and logic which we added. Developer are
so lazzy to write same code again and again and make create utils class
to make reusable code.
Here i am sharing list of function which we are
using in daily basis in android application development which will save
your time to find from Google or Stack overflow and write in your utils
class or java class. The main objective of this task is Reuse ability of
code , Time saving , Easy & Less coding. Let's start.
You have two ways to use this Utils function :
JAVA File
Live Template
Direct form JAVA file :
You just need to add my created Utils JAVA file in your <package>
and access using class object. You can find 120+ utils function in java
file but that is not mandatory to add all in your application you can
remove list of function which is not useful for your application so that
will not save unnecessary code. see below example to see "How to use this class in your activity class?"
public class MainActivity extends Activity {
private CKAndroidUtils objCKUtils;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
objCKUtils = new CKAndroidUtils(this);
if (objCKUtils.isNetworkAvailable()) {
….. //Do your task
}
}
Live Template :
Code completion can improve your productivity by reducing how much
you have to type, but there are situations when a more powerful tool is
needed. Thanks to Android Studio and IntelliJ, live templates make it
much easier to focus on just the things you care about. You can read one
of the grate article regarding Live Template . You have to create CKAndroidUtils
snippet file (XML) which contains your code in XML formate and that
will be use to access the function using short cut key : Ctrl + Alt +
Shift + J FUNCTION NAME .
How to create your share with others :
Path : File > Settings > Editor > Live Template > .. You can see Add or remove snippet code or template group from “+” or “-“ from right side button.
Now choose Android group or own created template to add snippet code. That will ask you Abbreviation = Function name , Description = What function do, Template text = your code, Type =
java , xml ,other. Apply > Ok Done! Now search it using give short
cut key and access function any where in your application.
Now you can share added snippet code to other developer and setup same file to get access.
Check out below steps to configure the XML :
Download CKAndroidUtils snippet file
Go to “/.Android Studio/config /templetes folder (by default is hide folder at user /dir)
i.e /home/sotsys073/.AndroidStudio/config/templetes
Paste “CKAndroidUtils” file in above /dir.
Restart android studio and check CKAndroidUtils is available in File >> Settings >> Live template >> CKAndroidUtils
Short cut to access function : Ctrl + Alt + Shift + J FUNCTION NAMENow you are able to add function in template and know how to use it . Download CKAndroidUtils.java file and create your snippet or use directly. Start it now!!! Hope this will relay helpful for all of you.
Note : Please add function which you are using in project and not listed in below list so that will be helpful for other
The main objective of this task is to show two markers (customer &
driver) base on the distance with appropriate zoom level. Driver
position will change base on location update & zoom level update
base on the new distance calculated between two markers.
What user can do ?
User can zoom in & zoom out map from center position.(customer will be always in center of the map)
If a driver changes his/her location from the previous location we will get notify in void onLocationChanged(Location location)this location will help us to calculate the distance between customer & driver.
How does it work ?
We will get a frequent update of driver location even app will kill
from a background as they will move on the path. Now calculate the
distance between customer & driver current location and update
driver marker. Now calculate Zoom level base on distance and update map
view to be more zoom in.
To achieve this we have used transparent image view over the map to zoom
in & zoom out and get touch event of the map. So while user scales
it from any X,Y position that will call onCameraChangeListner .Now we
will calculate zoom level inside onCameraChangeListner and set customer
marker to the center of the screen.
Now while driver change is location marker will move with animation and
map will zoom out as per location change. Hope this will help you a lot.
You can download sample code.