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

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Recently uploaded (20)

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.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