Understand and counteract against offensive security threats to your applications
Maximize your device's power and potential to suit your needs and curiosity
See exactly how your smartphone's OS is put together (and where the seams are)
Who This Book Is For This book is for anyone who wants to learn about Android security. Software developers, QA professionals, and beginner- to intermediate-level security professionals will find this book helpful. Basic knowledge of Android programming would be a plus.
What You Will Learn
Acquaint yourself with the fundamental building blocks of Android Apps in the right way
Pentest Android apps and perform various attacks in the real world using real case studies
Take a look at how your personal data can be stolen by malicious attackers
Understand the offensive maneuvers that hackers use
Discover how to defend against threats
Get to know the basic concepts of Android rooting
See how developers make mistakes that allow attackers to steal data from phones
Grasp ways to secure your Android apps and devices
Find out how remote attacks are possible on Android devices
In Detail With the mass explosion of Android mobile phones in the world, mobile devices have become an integral part of our everyday lives. Security of Android devices is a broad subject that should be part of our everyday lives to defend against ever-growing smartphone attacks. Everyone, starting with end users all the way up to developers and security professionals should care about android security.
Hacking Android is a step-by-step guide that will get you started with Android security. You'll begin your journey at the absolute basics, and then will slowly gear up to the concepts of Android rooting, application security assessments, malware, infecting APK files, and fuzzing. On this journey you'll get to grips with various tools and techniques that can be used in your everyday pentests. You'll gain the skills necessary to perform Android application vulnerability assessment and penetration testing and will create an Android pentesting lab.
Style and approach This comprehensive guide takes a step-by-step approach and is explained in a conversational and easy-to-follow style. Each topic is explained sequentially in the process of performing a successful penetration test. We also include detailed explanations as well as screenshots of the basic and advanced concepts.
This video show how to apply Android provided Material Theme to your Activity.
- Edit values/styles.xml to add a new style inherits from Android provided Material Theme: android:Theme.Material, android:Theme.Material.Light or android:Theme.Material.Light.DarkActionBar.
- Edit AndroidManifest.xml to use the new style.
- You have to change your MainActivity extends Activity. Otherwise the following error will happen: You need to use a Theme.AppCompat theme (or descendant) with this activity. The video also show how it display on Multi-Window Mode.
The class android.util.DisplayMetrics is a structure describing general information about a display, such as its size, density, and font scaling. Here show how to get display information (specially heightPixels and widthPixels) in Multi-Window Mode.
if(isInMultiWindowMode()){ textPrompt.setText("onCreate run In Multi Window Mode "); }else{ textPrompt.setText("onCreate run NOT In Multi Window Mode "); }
private void showDisplayInfo(){ DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm);
String strScreenDIP = ""; strScreenDIP += "The logical density of the display: " + dm.density + "\n"; strScreenDIP += "The screen density expressed as dots-per-inch: " + dm.densityDpi +"\n"; strScreenDIP += "The absolute height of the display in pixels: " + dm.heightPixels +"\n"; strScreenDIP += "The absolute width of the display in pixels: " + dm.widthPixels + "\n"; strScreenDIP += "A scaling factor for fonts displayed on the display: " + dm.scaledDensity + "\n"; strScreenDIP += "The exact physical pixels per inch of the screen in the X dimension: " + dm.xdpi + "\n"; strScreenDIP += "The exact physical pixels per inch of the screen in the Y dimension: " + dm.ydpi + "\n";
if(isInMultiWindowMode()){ textPrompt.setText("onCreate run In Multi Window Mode "); }else{ textPrompt.setText("onCreate run NOT In Multi Window Mode "); }
This example show how to detect and check if your app run in multi window mode, target Android N with Multi-Window Support, by calling isInMultiWindowMode() and override onMultiWindowModeChanged() methods.
if(isInMultiWindowMode()){ textPrompt.setText("onCreate run In Multi Window Mode "); }else{ textPrompt.setText("onCreate run NOT In Multi Window Mode "); } }
@Override public void onMultiWindowModeChanged(boolean isInMultiWindowMode) { super.onMultiWindowModeChanged(isInMultiWindowMode);
if(isInMultiWindowMode){ textPrompt.setText("It is In Multi Window Mode "); }else{ textPrompt.setText("It is NOT In Multi Window Mode "); } } }
Last post of Bluetooth LE example show how to "Scan specified BLE devices with ScanFilter". This post show how to connect to the device and display the supported service by the device.
// Handles various events fired by the Service. // ACTION_GATT_CONNECTED: connected to a GATT server. // ACTION_GATT_DISCONNECTED: disconnected from a GATT server. // ACTION_GATT_SERVICES_DISCOVERED: discovered GATT services. // ACTION_DATA_AVAILABLE: received data from the device. This can be a result of read // or notification operations. private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) { mConnected = true; updateConnectionState("GATT_CONNECTED"); } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) { mConnected = false; updateConnectionState("GATT_DISCONNECTED"); clearUI(); } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) { // Show all the supported services and characteristics on the user interface. displayGattServices(mBluetoothLeService.getSupportedGattServices()); } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) { displayData(intent.getStringExtra(BluetoothLeService.EXTRA_DATA));
// Demonstrates how to iterate through the supported GATT Services/Characteristics. // In this sample, we populate the data structure that is bound to the ExpandableListView // on the UI. private void displayGattServices(List<BluetoothGattService> gattServices) {
if (gattServices == null) return; String uuid = null; String unknownServiceString = "Unknown Service"; String unknownCharaString = "Unknown Characteristic"; ArrayList<HashMap<String, String>> gattServiceData = new ArrayList<HashMap<String, String>>(); ArrayList<ArrayList<HashMap<String, String>>> gattCharacteristicData = new ArrayList<ArrayList<HashMap<String, String>>>(); mGattCharacteristics = new ArrayList<ArrayList<BluetoothGattCharacteristic>>();
// Loops through available GATT Services. for (BluetoothGattService gattService : gattServices) { HashMap<String, String> currentServiceData = new HashMap<String, String>(); uuid = gattService.getUuid().toString(); currentServiceData.put( LIST_NAME, lookup(uuid, unknownServiceString)); currentServiceData.put(LIST_UUID, uuid); gattServiceData.add(currentServiceData);
ArrayList<HashMap<String, String>> gattCharacteristicGroupData = new ArrayList<HashMap<String, String>>(); List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics(); ArrayList<BluetoothGattCharacteristic> charas = new ArrayList<BluetoothGattCharacteristic>();
// Loops through available Characteristics. for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { charas.add(gattCharacteristic); HashMap<String, String> currentCharaData = new HashMap<String, String>(); uuid = gattCharacteristic.getUuid().toString(); currentCharaData.put( LIST_NAME, lookup(uuid, unknownCharaString)); currentCharaData.put(LIST_UUID, uuid); gattCharacteristicGroupData.add(currentCharaData);
SimpleExpandableListAdapter gattServiceAdapter = new SimpleExpandableListAdapter( this, gattServiceData, android.R.layout.simple_expandable_list_item_2, new String[] {LIST_NAME, LIST_UUID}, new int[] { android.R.id.text1, android.R.id.text2 }, gattCharacteristicData, android.R.layout.simple_expandable_list_item_2, new String[] {LIST_NAME, LIST_UUID}, new int[] { android.R.id.text1, android.R.id.text2 } ); mGattServicesList.setAdapter(gattServiceAdapter); }
// If a given GATT characteristic is selected, check for supported features. This sample // demonstrates 'Read' and 'Notify' features. See // http://d.android.com/reference/android/bluetooth/BluetoothGatt.html for the complete // list of supported characteristic features. private final ExpandableListView.OnChildClickListener servicesListClickListner = new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (mGattCharacteristics != null) { final BluetoothGattCharacteristic characteristic = mGattCharacteristics.get(groupPosition).get(childPosition); final int charaProp = characteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) { // If there is an active notification on a characteristic, clear // it first so it doesn't update the data field on the user interface. if (mNotifyCharacteristic != null) { mBluetoothLeService.setCharacteristicNotification( mNotifyCharacteristic, false); mNotifyCharacteristic = null; } mBluetoothLeService.readCharacteristic(characteristic); } if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { mNotifyCharacteristic = characteristic; mBluetoothLeService.setCharacteristicNotification( characteristic, true); } return true; } return false; } };
// Check if BLE is supported on the device. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, "BLUETOOTH_LE not supported in this device!", Toast.LENGTH_SHORT).show(); finish(); }
getBluetoothAdapterAndLeScanner();
// Checks if Bluetooth is supported on the device. if (mBluetoothAdapter == null) { Toast.makeText(this, "bluetoothManager.getAdapter()==null", Toast.LENGTH_SHORT).show(); finish(); return; }
listBluetoothDevice = new ArrayList<>(); adapterLeScanResult = new ArrayAdapter<BluetoothDevice>( this, android.R.layout.simple_list_item_1, listBluetoothDevice); listViewLE.setAdapter(adapterLeScanResult); listViewLE.setOnItemClickListener(scanResultOnItemClickListener);
mHandler = new Handler();
}
AdapterView.OnItemClickListener scanResultOnItemClickListener = new AdapterView.OnItemClickListener(){
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final BluetoothDevice device = (BluetoothDevice) parent.getItemAtPosition(position);
new AlertDialog.Builder(MainActivity.this) .setTitle(device.getName()) .setMessage(msg) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {
} }) .setNeutralButton("CONNECT", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Intent intent = new Intent(MainActivity.this, ControlActivity.class); intent.putExtra(ControlActivity.EXTRAS_DEVICE_NAME, device.getName()); intent.putExtra(ControlActivity.EXTRAS_DEVICE_ADDRESS, device.getAddress());
private String getBTDevieType(BluetoothDevice d){ String type = "";
switch (d.getType()){ case BluetoothDevice.DEVICE_TYPE_CLASSIC: type = "DEVICE_TYPE_CLASSIC"; break; case BluetoothDevice.DEVICE_TYPE_DUAL: type = "DEVICE_TYPE_DUAL"; break; case BluetoothDevice.DEVICE_TYPE_LE: type = "DEVICE_TYPE_LE"; break; case BluetoothDevice.DEVICE_TYPE_UNKNOWN: type = "DEVICE_TYPE_UNKNOWN"; break; default: type = "unknown..."; }
// Checks if Bluetooth is supported on the device. if (mBluetoothAdapter == null) { Toast.makeText(this, "bluetoothManager.getAdapter()==null", Toast.LENGTH_SHORT).show(); finish(); return; }
private void getBluetoothAdapterAndLeScanner(){ // Get BluetoothAdapter and BluetoothLeScanner. final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter(); mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();
mScanning = false; }
/* to call startScan (ScanCallback callback), Requires BLUETOOTH_ADMIN permission. Must hold ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get results. */ private void scanLeDevice(final boolean enable) { if (enable) { listBluetoothDevice.clear(); listViewLE.invalidateViews();
// Stops scanning after a pre-defined scan period. mHandler.postDelayed(new Runnable() { @Override public void run() { mBluetoothLeScanner.stopScan(scanCallback); listViewLE.invalidateViews();
//scan specified devices only with ScanFilter ScanFilter scanFilter = new ScanFilter.Builder() .setServiceUuid(BluetoothLeService.ParcelUuid_GENUINO101_ledService) .build(); List<ScanFilter> scanFilters = new ArrayList<ScanFilter>(); scanFilters.add(scanFilter);
ScanSettings scanSettings = new ScanSettings.Builder().build();
seekBarZ1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { image1.setZ(i); } }
@Override public void onStartTrackingTouch(SeekBar seekBar) {}
@Override public void onStopTrackingTouch(SeekBar seekBar) {} });
seekBarZ2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { text2.setZ(i); text2.setText("elevation: " + String.valueOf(i) + "px"); } }
@Override public void onStartTrackingTouch(SeekBar seekBar) {}
@Override public void onStopTrackingTouch(SeekBar seekBar) {} }); } }
Design custom apps that interact with the outside world via BeagleBone Black
Modify Android to recognize, configure, and communicate with sensors, LEDs, memory, and more
A step-by-step guide full of practical Android app examples that will help the users to create Android controlled devices that will use BeagleBone as hardware
Who This Book Is For If you are an Android app developer who wants to experiment with the hardware capabilities of the BeagleBone Black platform, then this book is ideal for you. You are expected to have basic knowledge of developing Android apps but no prior hardware experience is required.
What You Will Learn
Install Android on your BeagleBone Black
Explore the three primary hardware interfaces of the BeagleBone Black—GPIO, SPI, and I2C
Construct circuits that interface the BeagleBone Black with high-speed sensors, external memory chips, and more
Discover the advantages and disadvantages of using GPIO, I2C, and SPI components in your interfacing projects
Modify Android to recognize and interface with your own custom and prototype hardware
Develop multithreaded apps that communicate directly with custom circuitry
In Detail This book explores using the Android OS on the BeagleBone Black hardware platform and provides an introduction to Android's unique approach to hardware interfacing. You'll be walked through the process of installing and configuring Android on your BeagleBone Black, as well as preparing your PC development environment to create Android applications that directly interface with hardware devices. Several example projects within this book introduce you to using the GPIO, SPI, and I2C hardware interfaces of the BeagleBone Black.
You'll create Android apps that communicate directly with actual hardware components such as sensors, memory chips, switches, and LEDs. Step-by-step guidance through both the software and hardware portions of these projects is provided. Combining all of the previous projects into a single project that uses GPIO, SPI, and I2C together, you will explore the details of creating an advanced hardware interfacing app. Finally, you'll be provided with information on transitioning prototype code into code suitable for deployment on an Android-based device. With a variety of example apps that demonstrate key hardware communication concepts, this book will help you become an Android hardware interfacing pro in no time.
Create engaging apps with fragments to provide a rich user interface that dynamically adapts to the individual characteristics of your customers' tablets and smartphones
From an eminent author comes a book that will help you create engaging apps that dynamically adapt to individual device characteristics
The only book that includes the latest fragment-oriented features and their role in Material design
This book provides code-intensive discussions and detailed examples that help you understand better and learn faster.
Who This Book Is For This book is for developers with a basic understanding of Android programming who would like to improve the appearance and usability of their applications by creating a more interactive user experience and dynamically adaptive UIs; providing better support for tablets and smartphones in a single app; and reducing the complexity of managing app UIs.
What You Will Learn
Learn the role and capabilities of fragments
Use Android Studio's fragment-oriented features
Create an app UI that works effectively on smartphones and tablets
Manage the creation and life cycle of fragments
Dynamically manage fragments using the FragmentTransaction class
Learn the application design for communicating between fragments
Leverage fragments when implementing applications that take advantage of the latest features of Material Design
In Detail Today's users expect mobile apps to be dynamic and highly interactive, with rich navigation features. These same apps must look fantastic whether running on a medium-resolution smartphone or high-resolution tablet. Fragments provide the toolset we need to meet these user expectations by enabling us to build our applications out of adaptable components that take advantage of the rich capabilities of each individual device and automatically adapt to their differences.
This book looks at the impact fragments have on Android UI design and their role in both simplifying many common UI challenges and in providing best practices for incorporating rich UI behaviors. We look closely at the roll of fragment transactions and how to work with the Android back stack. Leveraging this understanding, we explore several specialized fragment-related classes such as ListFragment and DialogFragment. We then go on to discuss how to implement rich navigation features such as swipe-based screen browsing, and the role of fragments when developing applications that take advantage of the latest aspects of Material Design.
You will learn everything you need to provide dynamic, multi-screen UIs within a single activity, and the rich UI features demanded by today's mobile users.
Style and approach A fast-paced learning guide that gives a hands-on, code-intensive approach with a focus on real-world applications.
This video show how to stream Camera Module NoIR V2 video from Raspberry Pi 3/Raspbian Jessie using vlc, play in Android App with VideoView. Details, refer my another blogspot.
seekBarZ.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { image.setZ(i); } }
@Override public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override public void onStopTrackingTouch(SeekBar seekBar) {
MPAndroidChart is a powerful Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging and animations. This video show how to download and run its example in Android Studio/Emulator.