SlideShare a Scribd company logo
1 of 36
1/82
2/82
Api & Debugging In AndroidApi & Debugging In Android
3/82
1 ADDITIONAL API FEATURES
DEBUGGING2
OPTIMISATIONS3
4/82
1 ADDITIONAL API FEATURES
DEBUGGING2
OPTIMISATIONS3
5/82
More on API | 2DMore on API | 2D
Bitmap image;
image = BitmapFactory.decodeResource(getResources(),R.drawable.image1);
// getPixel(), setPixel()
image = BitmapFactory.decodeFile(“path/to/image/on/SDcard”);
// Environment.getExternalStorageDirectory().getAbsolutePath()
6/82
More on API |More on API | 2D2D
public class MyGUIcomponent extends View {
private Paint paint;
public MyGUIcomponent(Context c){
paint = new Paint();
paint.setColor(Color.WHITE);
paint.setTextSize(25);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawText(“some text”, 5, 30, paint);
}
@Override
protected void onMeasure(int w, int h){
// w = ...; h = ...;
setMeasuredDimension(w, h);
}
}
7/82
More on API | 3DMore on API | 3D
• OpenGL library
• Camera, matrices, transformations, ...
• View animation
8/82
More on API | audio/videoMore on API | audio/video
<uses-permission android:name=“android.permission.RECORD_VIDEO” />
9/82
More on API | hardwareMore on API | hardware
• Camera
• Phone
• Sensors
• WiFi
• Bluetooth
• GPS (Location services/Maps)
10/82
More on API | sensorsMore on API | sensors
• Accelerometer
• Thermometer
• Compass
• Light sensor
• Barometer
• Proximity sensor
11/82
More on API | sensorsMore on API | sensors
• A list of all sensors
o getSensorList()
• Control class
o SensorManager
• Callback methods
o onSensorChanged()
o onAccuracyChanged()
12/82
More on API | sensorsMore on API | sensors
private void initAccel(){
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
mSens = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mSens,
SensorManager.SENSOR_DELAY_GAME);
}
@Override
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == SensorManager.SENSOR_ACCELEROMETER) {
float x = event.values[SensorManager.DATA_X];
float y = event.values[SensorManager.DATA_Y];
float z = event.values[SensorManager.DATA_Z];
}
}
13/82
More on API | wifiMore on API | wifi
<uses-permission android:name=“android.permission.ACCESS_NETWORK_STATE”
/>
private BroadcastReceiver mNetworkReceiver = new BroadcastReceiver(){
public void onReceive(Context c, Intent i){
Bundle b = i.getExtras();
NetworkInfo info =
(NetworkInfo) b.get(ConnectivityManager.EXTRA_NETWORK_INFO);
if(info.isConnected()){
//...
}else{
// no connection
}
}
};
this.registerReceiver(mNetworkReceiver,
new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
14/82
More on API | iMore on API | internetnternet
• Social network apps
• Cloud apps
• Sockets, Datagrams, Http, ...
15/82
More on API | smsMore on API | sms
SmsManager mySMS = SmsManager.getDefault();
String to_whom = “+4475...”;
String message_text = “...”;
mojSMS.sendTextMessage(to_whom, null, message_text, null, null);
<uses-permission android:name=“android.permission.SEND_SMS” />
<uses-permission android:name=“android.permission.RECEIVE_SMS” />
ArrayList<String> multiSMS = mySMS.divideMessage(poruka);
mySMS.sendMultipartTextMessage(to_whom, null, multiSMS, null, null);
16/82
More on API | smsMore on API | sms
BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context c, Intent in) {
if(in.getAction().equals(RECEIVED_ACTION)) {
Bundle bundle = in.getExtras();
if(bundle!=null) {
Object[] pdus = (Object[])bundle.get(“pdus”);
SmsMessage[] msgs = new SmsMessage[pdus.length];
for(int i = 0; i<pdus.length; i++) {
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
}
// reply();
}
}
}};
17/82
More on API | smsMore on API | sms
public class ResponderService extends Service {
private static final String RECEIVED_ACTION =
“android.provider.Telephony.SMS_RECEIVED”;
@Override
public void onCreate() {
super.onCreate();
registerReceiver(receiver, new IntentFilter(RECEIVED_ACTION));
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId); }
@Override
public void onDestroy() {
super.onDestroy(); unregisterReceiver(receiver); }
@Override
public IBinder onBind(Intent arg0) { return null; }
}
18/82
More on API | sMore on API | sharedPreferencesharedPreferences
• Interface for easy storage of key-value pairs
• Mostly used for saving user settings (language, etc.)
o e.g. username/pass combination for auto-login
• Access to file
o MODE_PRIVATE
o MODE_WORLD_READABLE
o MODE_WORLD_WRITEABLE
19/82
More on API | sMore on API | sharedPreferencesharedPreferences
SharedPreferences prefs = getSharedPreferences(“Name”, MODE_PRIVATE);
Editor mEditor = prefs.edit();
mEditor.putString(“username”, username);
mEditor.putString(“password”, password);
mEditor.commit();
SharedPreferences prefs = getSharedPreferences(“Name”, MODE_PRIVATE);
String username = prefs.getString(“username”, “”);
String password = prefs.getString(“password”, “”);
20/82
More on API |More on API | sqlsqliteite
• Each application has its own DB (can be shared)
• /data/data/<you_package>/databases
• Can
o Create a db
o Open a db
o Create tables
o Insert data into tables
o Fetch data from tables
o Close a db
• Basically, SQL syntax
21/82
More on API | contentProviderMore on API | contentProvider
• Since every application is sandboxed, this is Androids
mechanism which relates data across apps
• Required access privileges must be declared in Manifest
and approved by user during installation
22/82
More on API | java.io.FileMore on API | java.io.File
FileInputStream fis = openFileInput(“some_file.txt”);
FileOutputStream fos = openFileOutput(“some_file.txt”,
Context.MODE_WORLD_WRITEABLE);
Bitmap slika;
FileOutputStream new_profile_image = openFileOutput(“new_image.png”,
Context.MODE_WORLD_WRITEABLE);
slika.compress(CompressFormat.PNG, 100, new_profile_image);
out.flush();
out.close();
InputStream is =
this.getResource().openRawResource(R.raw.some_raw_file);
23/82
1 ADDITIONAL API FEATURES
DEBUGGING2
OPTIMISATIONS3
24/82
DebugDebuggingging
• gdb
o Since it’s based on Linux, similar command-set
• DDMS through ADT
o Dalvik Debug Monitoring Service
o Android Developer Tools plugin for Eclipse
o Using breakpoints
• Android SDK Debug tools
o ADB (Android Debug Bridge)
o LogCat
o HierarchyViewer
25/82
DebugDebugging | gdbging | gdb
> adb shell top
> adb shell ps
> gdb mojprogram
> adb logcat
26/82
DebugDebugging | ddmsging | ddms
27/82
DebugDebugging | aging | androidndroid ddebugebug bbridgeridge
• Controlling an emulator instance
> adb start-server
> adb stop-server
28/82
DebugDebugging |ging | LogCatLogCat
• Logging app execution
• Real-time logging tool
• Works with tags, priorities and filters
29/82
DebugDebugging | hging | hierarchyierarchy vvieweriewer
• For “interface debugging”
30/82
1 ADDITIONAL API FEATURES
DEBUGGING2
OPTIMISATIONS3
31/82
Optimisations | in generalOptimisations | in general
• Instancing objects is expensive, avoid if possible
o Overhead from creating, allocation and GC-ing
• Use native methods
o written in C/C++
o around 10-100x faster than user-written in Java by user
• Calls through interfaces are up to 2x slower than virtual
• Declare methods as static if they don’t need access to
object’s fields
• Caching field access results
o counters, etc.
Map myMapa = new HashMap();
HashMap myMapa = new HashMap();
32/82
Optimisations |Optimisations | getView()getView()
• Implemented in Adapter
• Used for:
o Fetching elements from XML
o Their creation in memory (inflate)
o Filling them with valid data
o Returning a ready View element
private static class SomeAdapter extends BaseAdapter {
public SomeAdapter(Context context) {}
public int getCount() { /*...*/ }
public Object getItem(int position) { /*...*/ }
public long getItemId(int position) { /*...*/ }
public View getView(int p, View cv, ViewGroup p) {
// this implementation directly impacts performace
}
}
33/82
Optimisations |Optimisations | getView()getView()
• Creation of a new element gets called each time, and
that is the single most expensive operation when dealing
with UI
public View getView(int p, View cv, ViewGroup p) {
View element = //... make a new View
element.text = //... get element from XML
element.icon = //... get element from XML
return element;
}
34/82
Optimisations |Optimisations | getView()getView()
• New element get created only a couple of times
• Performance is acceptable
public View getView(int p, View cv, ViewGroup p) {
if (cv == null) {
cv = //... make a new View
}
cv.text = //... get element from XML
cv.icon = //... get element from XML
return cv;
}
35/82
Optimisations |Optimisations | getView()getView()
static class ViewHolder {
TextView text;
ImageView icon;
}
public View getView(int p, View cv, ViewGroup p) {
ViewHolder holder;
if (cv == null) {
cv = //... make a new View
holder = new ViewHolder();
holder.text = //... get element from XML
holder.icon = //... get element from XML
cv.setTag(holder);
} else {
holder = (ViewHolder) cv.getTag();
}
return cv;
}
36/82
ThankThank You !!!You !!!
For More Information click below link:
Follow Us on:
http://vibranttechnologies.co.in/android-classes-in-mumbai.html

More Related Content

What's hot

Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App EngineIndicThreads
 
What's cool in the new and updated OSGi Specs (EclipseCon 2014)
What's cool in the new and updated OSGi Specs (EclipseCon 2014)What's cool in the new and updated OSGi Specs (EclipseCon 2014)
What's cool in the new and updated OSGi Specs (EclipseCon 2014)David Bosschaert
 
Anton Minashkin Dagger 2 light
Anton Minashkin Dagger 2 lightAnton Minashkin Dagger 2 light
Anton Minashkin Dagger 2 lightMichael Pustovit
 
Indic threads pune12-java ee 7 platformsimplification html5
Indic threads pune12-java ee 7 platformsimplification html5Indic threads pune12-java ee 7 platformsimplification html5
Indic threads pune12-java ee 7 platformsimplification html5IndicThreads
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/ServletSunil OS
 
Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limitsDroidcon Berlin
 
A friend in need - A JS indeed
A friend in need - A JS indeedA friend in need - A JS indeed
A friend in need - A JS indeedYonatan Levin
 
What's new in Android O
What's new in Android OWhat's new in Android O
What's new in Android OKirill Rozov
 
Data binding в массы! (1.2)
Data binding в массы! (1.2)Data binding в массы! (1.2)
Data binding в массы! (1.2)Yurii Kotov
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsHassan Abid
 
Provisioning with OSGi Subsystems and Repository using Apache Aries and Felix
Provisioning with OSGi Subsystems and Repository using Apache Aries and FelixProvisioning with OSGi Subsystems and Repository using Apache Aries and Felix
Provisioning with OSGi Subsystems and Repository using Apache Aries and FelixDavid Bosschaert
 
안드로이드 데이터 바인딩
안드로이드 데이터 바인딩안드로이드 데이터 바인딩
안드로이드 데이터 바인딩GDG Korea
 
Spring 4 advanced final_xtr_presentation
Spring 4 advanced final_xtr_presentationSpring 4 advanced final_xtr_presentation
Spring 4 advanced final_xtr_presentationsourabh aggarwal
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenchesLukas Smith
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right wayThibaud Desodt
 
Daggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processorDaggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processorBartosz Kosarzycki
 
Networking and Data Access with Eqela
Networking and Data Access with EqelaNetworking and Data Access with Eqela
Networking and Data Access with Eqelajobandesther
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM patternNAVER Engineering
 

What's hot (20)

Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App Engine
 
What's cool in the new and updated OSGi Specs (EclipseCon 2014)
What's cool in the new and updated OSGi Specs (EclipseCon 2014)What's cool in the new and updated OSGi Specs (EclipseCon 2014)
What's cool in the new and updated OSGi Specs (EclipseCon 2014)
 
Anton Minashkin Dagger 2 light
Anton Minashkin Dagger 2 lightAnton Minashkin Dagger 2 light
Anton Minashkin Dagger 2 light
 
Indic threads pune12-java ee 7 platformsimplification html5
Indic threads pune12-java ee 7 platformsimplification html5Indic threads pune12-java ee 7 platformsimplification html5
Indic threads pune12-java ee 7 platformsimplification html5
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limits
 
A friend in need - A JS indeed
A friend in need - A JS indeedA friend in need - A JS indeed
A friend in need - A JS indeed
 
What's new in Android O
What's new in Android OWhat's new in Android O
What's new in Android O
 
Data binding в массы! (1.2)
Data binding в массы! (1.2)Data binding в массы! (1.2)
Data binding в массы! (1.2)
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
 
Provisioning with OSGi Subsystems and Repository using Apache Aries and Felix
Provisioning with OSGi Subsystems and Repository using Apache Aries and FelixProvisioning with OSGi Subsystems and Repository using Apache Aries and Felix
Provisioning with OSGi Subsystems and Repository using Apache Aries and Felix
 
안드로이드 데이터 바인딩
안드로이드 데이터 바인딩안드로이드 데이터 바인딩
안드로이드 데이터 바인딩
 
Spring 4 advanced final_xtr_presentation
Spring 4 advanced final_xtr_presentationSpring 4 advanced final_xtr_presentation
Spring 4 advanced final_xtr_presentation
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right way
 
Daggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processorDaggerate your code - Write your own annotation processor
Daggerate your code - Write your own annotation processor
 
Networking and Data Access with Eqela
Networking and Data Access with EqelaNetworking and Data Access with Eqela
Networking and Data Access with Eqela
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern
 
Android classes in mumbai
Android classes in mumbaiAndroid classes in mumbai
Android classes in mumbai
 

Similar to Android - Api & Debugging in Android

Android training in mumbai
Android training in mumbaiAndroid training in mumbai
Android training in mumbaiCIBIL
 
Android tutorial (2)
Android tutorial (2)Android tutorial (2)
Android tutorial (2)Kumar
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEBenjamin Cabé
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the TrenchesJonathan Wage
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'sAntônio Roberto Silva
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersJiaxuan Lin
 
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rulesSrijan Technologies
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsMatteo Manchi
 
Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Jesus Manuel Olivas
 
Cloud nativemicroservices jax-london2020
Cloud nativemicroservices   jax-london2020Cloud nativemicroservices   jax-london2020
Cloud nativemicroservices jax-london2020Emily Jiang
 
Cloud nativemicroservices jax-london2020
Cloud nativemicroservices   jax-london2020Cloud nativemicroservices   jax-london2020
Cloud nativemicroservices jax-london2020Emily Jiang
 
Cloud nativeworkshop
Cloud nativeworkshopCloud nativeworkshop
Cloud nativeworkshopEmily Jiang
 
Master a Cloud Native Standard - MicroProfile.pptx
Master a Cloud Native Standard - MicroProfile.pptxMaster a Cloud Native Standard - MicroProfile.pptx
Master a Cloud Native Standard - MicroProfile.pptxEmilyJiang23
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WAREFermin Galan
 
What's new in android jakarta gdg (2015-08-26)
What's new in android   jakarta gdg (2015-08-26)What's new in android   jakarta gdg (2015-08-26)
What's new in android jakarta gdg (2015-08-26)Google
 
Android architecture
Android architecture Android architecture
Android architecture Trong-An Bui
 

Similar to Android - Api & Debugging in Android (20)

Android - Anatomy of android elements & layouts
Android - Anatomy of android elements & layoutsAndroid - Anatomy of android elements & layouts
Android - Anatomy of android elements & layouts
 
Android training in mumbai
Android training in mumbaiAndroid training in mumbai
Android training in mumbai
 
Android tutorial (2)
Android tutorial (2)Android tutorial (2)
Android tutorial (2)
 
Android For All The Things
Android For All The ThingsAndroid For All The Things
Android For All The Things
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Android Froyo
Android FroyoAndroid Froyo
Android Froyo
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 
Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...
 
Cloud nativemicroservices jax-london2020
Cloud nativemicroservices   jax-london2020Cloud nativemicroservices   jax-london2020
Cloud nativemicroservices jax-london2020
 
Cloud nativemicroservices jax-london2020
Cloud nativemicroservices   jax-london2020Cloud nativemicroservices   jax-london2020
Cloud nativemicroservices jax-london2020
 
Hexagonal architecture in PHP
Hexagonal architecture in PHPHexagonal architecture in PHP
Hexagonal architecture in PHP
 
Cloud nativeworkshop
Cloud nativeworkshopCloud nativeworkshop
Cloud nativeworkshop
 
Master a Cloud Native Standard - MicroProfile.pptx
Master a Cloud Native Standard - MicroProfile.pptxMaster a Cloud Native Standard - MicroProfile.pptx
Master a Cloud Native Standard - MicroProfile.pptx
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
 
What's new in android jakarta gdg (2015-08-26)
What's new in android   jakarta gdg (2015-08-26)What's new in android   jakarta gdg (2015-08-26)
What's new in android jakarta gdg (2015-08-26)
 
Android architecture
Android architecture Android architecture
Android architecture
 

More from Vibrant Technologies & Computers

Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Vibrant Technologies & Computers
 

More from Vibrant Technologies & Computers (20)

Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
 
SQL- Introduction to SQL database
SQL- Introduction to SQL database SQL- Introduction to SQL database
SQL- Introduction to SQL database
 
ITIL - introduction to ITIL
ITIL - introduction to ITILITIL - introduction to ITIL
ITIL - introduction to ITIL
 
Salesforce - Introduction to Security & Access
Salesforce -  Introduction to Security & Access Salesforce -  Introduction to Security & Access
Salesforce - Introduction to Security & Access
 
Data ware housing- Introduction to olap .
Data ware housing- Introduction to  olap .Data ware housing- Introduction to  olap .
Data ware housing- Introduction to olap .
 
Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.
 
Data ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housingData ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housing
 
Salesforce - classification of cloud computing
Salesforce - classification of cloud computingSalesforce - classification of cloud computing
Salesforce - classification of cloud computing
 
Salesforce - cloud computing fundamental
Salesforce - cloud computing fundamentalSalesforce - cloud computing fundamental
Salesforce - cloud computing fundamental
 
SQL- Introduction to PL/SQL
SQL- Introduction to  PL/SQLSQL- Introduction to  PL/SQL
SQL- Introduction to PL/SQL
 
SQL- Introduction to advanced sql concepts
SQL- Introduction to  advanced sql conceptsSQL- Introduction to  advanced sql concepts
SQL- Introduction to advanced sql concepts
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 
SQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set OperationsSQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set Operations
 
Sas - Introduction to designing the data mart
Sas - Introduction to designing the data martSas - Introduction to designing the data mart
Sas - Introduction to designing the data mart
 
Sas - Introduction to working under change management
Sas - Introduction to working under change managementSas - Introduction to working under change management
Sas - Introduction to working under change management
 
SAS - overview of SAS
SAS - overview of SASSAS - overview of SAS
SAS - overview of SAS
 
Teradata - Architecture of Teradata
Teradata - Architecture of TeradataTeradata - Architecture of Teradata
Teradata - Architecture of Teradata
 
Teradata - Restoring Data
Teradata - Restoring Data Teradata - Restoring Data
Teradata - Restoring Data
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Android - Api & Debugging in Android

  • 2. 2/82 Api & Debugging In AndroidApi & Debugging In Android
  • 3. 3/82 1 ADDITIONAL API FEATURES DEBUGGING2 OPTIMISATIONS3
  • 4. 4/82 1 ADDITIONAL API FEATURES DEBUGGING2 OPTIMISATIONS3
  • 5. 5/82 More on API | 2DMore on API | 2D Bitmap image; image = BitmapFactory.decodeResource(getResources(),R.drawable.image1); // getPixel(), setPixel() image = BitmapFactory.decodeFile(“path/to/image/on/SDcard”); // Environment.getExternalStorageDirectory().getAbsolutePath()
  • 6. 6/82 More on API |More on API | 2D2D public class MyGUIcomponent extends View { private Paint paint; public MyGUIcomponent(Context c){ paint = new Paint(); paint.setColor(Color.WHITE); paint.setTextSize(25); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawText(“some text”, 5, 30, paint); } @Override protected void onMeasure(int w, int h){ // w = ...; h = ...; setMeasuredDimension(w, h); } }
  • 7. 7/82 More on API | 3DMore on API | 3D • OpenGL library • Camera, matrices, transformations, ... • View animation
  • 8. 8/82 More on API | audio/videoMore on API | audio/video <uses-permission android:name=“android.permission.RECORD_VIDEO” />
  • 9. 9/82 More on API | hardwareMore on API | hardware • Camera • Phone • Sensors • WiFi • Bluetooth • GPS (Location services/Maps)
  • 10. 10/82 More on API | sensorsMore on API | sensors • Accelerometer • Thermometer • Compass • Light sensor • Barometer • Proximity sensor
  • 11. 11/82 More on API | sensorsMore on API | sensors • A list of all sensors o getSensorList() • Control class o SensorManager • Callback methods o onSensorChanged() o onAccuracyChanged()
  • 12. 12/82 More on API | sensorsMore on API | sensors private void initAccel(){ mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mSens = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(this, mSens, SensorManager.SENSOR_DELAY_GAME); } @Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == SensorManager.SENSOR_ACCELEROMETER) { float x = event.values[SensorManager.DATA_X]; float y = event.values[SensorManager.DATA_Y]; float z = event.values[SensorManager.DATA_Z]; } }
  • 13. 13/82 More on API | wifiMore on API | wifi <uses-permission android:name=“android.permission.ACCESS_NETWORK_STATE” /> private BroadcastReceiver mNetworkReceiver = new BroadcastReceiver(){ public void onReceive(Context c, Intent i){ Bundle b = i.getExtras(); NetworkInfo info = (NetworkInfo) b.get(ConnectivityManager.EXTRA_NETWORK_INFO); if(info.isConnected()){ //... }else{ // no connection } } }; this.registerReceiver(mNetworkReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
  • 14. 14/82 More on API | iMore on API | internetnternet • Social network apps • Cloud apps • Sockets, Datagrams, Http, ...
  • 15. 15/82 More on API | smsMore on API | sms SmsManager mySMS = SmsManager.getDefault(); String to_whom = “+4475...”; String message_text = “...”; mojSMS.sendTextMessage(to_whom, null, message_text, null, null); <uses-permission android:name=“android.permission.SEND_SMS” /> <uses-permission android:name=“android.permission.RECEIVE_SMS” /> ArrayList<String> multiSMS = mySMS.divideMessage(poruka); mySMS.sendMultipartTextMessage(to_whom, null, multiSMS, null, null);
  • 16. 16/82 More on API | smsMore on API | sms BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context c, Intent in) { if(in.getAction().equals(RECEIVED_ACTION)) { Bundle bundle = in.getExtras(); if(bundle!=null) { Object[] pdus = (Object[])bundle.get(“pdus”); SmsMessage[] msgs = new SmsMessage[pdus.length]; for(int i = 0; i<pdus.length; i++) { msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]); } // reply(); } } }};
  • 17. 17/82 More on API | smsMore on API | sms public class ResponderService extends Service { private static final String RECEIVED_ACTION = “android.provider.Telephony.SMS_RECEIVED”; @Override public void onCreate() { super.onCreate(); registerReceiver(receiver, new IntentFilter(RECEIVED_ACTION)); } @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); } @Override public void onDestroy() { super.onDestroy(); unregisterReceiver(receiver); } @Override public IBinder onBind(Intent arg0) { return null; } }
  • 18. 18/82 More on API | sMore on API | sharedPreferencesharedPreferences • Interface for easy storage of key-value pairs • Mostly used for saving user settings (language, etc.) o e.g. username/pass combination for auto-login • Access to file o MODE_PRIVATE o MODE_WORLD_READABLE o MODE_WORLD_WRITEABLE
  • 19. 19/82 More on API | sMore on API | sharedPreferencesharedPreferences SharedPreferences prefs = getSharedPreferences(“Name”, MODE_PRIVATE); Editor mEditor = prefs.edit(); mEditor.putString(“username”, username); mEditor.putString(“password”, password); mEditor.commit(); SharedPreferences prefs = getSharedPreferences(“Name”, MODE_PRIVATE); String username = prefs.getString(“username”, “”); String password = prefs.getString(“password”, “”);
  • 20. 20/82 More on API |More on API | sqlsqliteite • Each application has its own DB (can be shared) • /data/data/<you_package>/databases • Can o Create a db o Open a db o Create tables o Insert data into tables o Fetch data from tables o Close a db • Basically, SQL syntax
  • 21. 21/82 More on API | contentProviderMore on API | contentProvider • Since every application is sandboxed, this is Androids mechanism which relates data across apps • Required access privileges must be declared in Manifest and approved by user during installation
  • 22. 22/82 More on API | java.io.FileMore on API | java.io.File FileInputStream fis = openFileInput(“some_file.txt”); FileOutputStream fos = openFileOutput(“some_file.txt”, Context.MODE_WORLD_WRITEABLE); Bitmap slika; FileOutputStream new_profile_image = openFileOutput(“new_image.png”, Context.MODE_WORLD_WRITEABLE); slika.compress(CompressFormat.PNG, 100, new_profile_image); out.flush(); out.close(); InputStream is = this.getResource().openRawResource(R.raw.some_raw_file);
  • 23. 23/82 1 ADDITIONAL API FEATURES DEBUGGING2 OPTIMISATIONS3
  • 24. 24/82 DebugDebuggingging • gdb o Since it’s based on Linux, similar command-set • DDMS through ADT o Dalvik Debug Monitoring Service o Android Developer Tools plugin for Eclipse o Using breakpoints • Android SDK Debug tools o ADB (Android Debug Bridge) o LogCat o HierarchyViewer
  • 25. 25/82 DebugDebugging | gdbging | gdb > adb shell top > adb shell ps > gdb mojprogram > adb logcat
  • 27. 27/82 DebugDebugging | aging | androidndroid ddebugebug bbridgeridge • Controlling an emulator instance > adb start-server > adb stop-server
  • 28. 28/82 DebugDebugging |ging | LogCatLogCat • Logging app execution • Real-time logging tool • Works with tags, priorities and filters
  • 29. 29/82 DebugDebugging | hging | hierarchyierarchy vvieweriewer • For “interface debugging”
  • 30. 30/82 1 ADDITIONAL API FEATURES DEBUGGING2 OPTIMISATIONS3
  • 31. 31/82 Optimisations | in generalOptimisations | in general • Instancing objects is expensive, avoid if possible o Overhead from creating, allocation and GC-ing • Use native methods o written in C/C++ o around 10-100x faster than user-written in Java by user • Calls through interfaces are up to 2x slower than virtual • Declare methods as static if they don’t need access to object’s fields • Caching field access results o counters, etc. Map myMapa = new HashMap(); HashMap myMapa = new HashMap();
  • 32. 32/82 Optimisations |Optimisations | getView()getView() • Implemented in Adapter • Used for: o Fetching elements from XML o Their creation in memory (inflate) o Filling them with valid data o Returning a ready View element private static class SomeAdapter extends BaseAdapter { public SomeAdapter(Context context) {} public int getCount() { /*...*/ } public Object getItem(int position) { /*...*/ } public long getItemId(int position) { /*...*/ } public View getView(int p, View cv, ViewGroup p) { // this implementation directly impacts performace } }
  • 33. 33/82 Optimisations |Optimisations | getView()getView() • Creation of a new element gets called each time, and that is the single most expensive operation when dealing with UI public View getView(int p, View cv, ViewGroup p) { View element = //... make a new View element.text = //... get element from XML element.icon = //... get element from XML return element; }
  • 34. 34/82 Optimisations |Optimisations | getView()getView() • New element get created only a couple of times • Performance is acceptable public View getView(int p, View cv, ViewGroup p) { if (cv == null) { cv = //... make a new View } cv.text = //... get element from XML cv.icon = //... get element from XML return cv; }
  • 35. 35/82 Optimisations |Optimisations | getView()getView() static class ViewHolder { TextView text; ImageView icon; } public View getView(int p, View cv, ViewGroup p) { ViewHolder holder; if (cv == null) { cv = //... make a new View holder = new ViewHolder(); holder.text = //... get element from XML holder.icon = //... get element from XML cv.setTag(holder); } else { holder = (ViewHolder) cv.getTag(); } return cv; }
  • 36. 36/82 ThankThank You !!!You !!! For More Information click below link: Follow Us on: http://vibranttechnologies.co.in/android-classes-in-mumbai.html