+ All Categories
Home > Documents > Introduction to Android Internals_Omar_Ayed

Introduction to Android Internals_Omar_Ayed

Date post: 18-Aug-2015
Category:
Upload: omar-ayed
View: 11 times
Download: 0 times
Share this document with a friend
22
Introduction to Android Internals 2014/2015 Lecturer : Ron Monitz Student : Omar Ayed
Transcript
Page 1: Introduction to Android Internals_Omar_Ayed

Introduction to Android Internals

2014/2015

Lecturer : Ron MonitzStudent : Omar Ayed

Page 2: Introduction to Android Internals_Omar_Ayed

Requirements

You need to have the following installed and configured on your development machine:

Android SDK and platform tools.

Eclipse IDE 3.7.2 or higher with the ADT plugin.

an emulator or Android device running Android 2.2 or higher.

Page 3: Introduction to Android Internals_Omar_Ayed

What is Kiosk Mode

Kiosk mode applications are applications that lock the device and do not allow the user to run any other application other than the kiosk application.Android doesn't allow true kiosk mode without building a custom ROM.However using the following methods you can build an application that will prevent "regular" users from playing with anything other than your application.

There are couple of methods to developer a Kiosk mode application: Code Tweak. Custom Build Rom. AOSP (Android Open Source Project).

Page 5: Introduction to Android Internals_Omar_Ayed

Create new project

Import the project that you download it before in eclipse and delete all the unnecessary files (like the files in the src folder and xml files ) , then add your app files (put the Classes in src folder and the xml files in the res/layout folder )Also add the video in the res/raw folder to play it when the app launched .

Page 6: Introduction to Android Internals_Omar_Ayed

Project Manifest

The next step is modifying the AndroidManifest.xml file by adding code to the main activity to displays it in home screen.

<activity android:name="com.android.launcher2.MainActivity" android:label="@string/app_name"

android:screenOrientation="landscape" android:hardwareAccelerated="true" android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen" android:launchMode="singleTask" android:stateNotNeeded="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.HOME" /> </intent-filter> </activity>

Page 7: Introduction to Android Internals_Omar_Ayed

ContinueBy adding the categories android.intent.category.HOME and android.intent.category.DEFAULT to the intent-filter group, the associated Activity behaves like a launcher and shows up as an option when you press the device's home button.

We also need to set the launchMode to singleTask to make sure that only one instance of this Activity is held by the system at any time. To show the user's wallpaper, set the theme to Theme.Wallpaper.NoTitleBar.FullScreen.

Page 8: Introduction to Android Internals_Omar_Ayed

Activity Layouts

Create an XML file for the MainActivity class in the project's res/layout folder and name it activity_main.xml. The layout has a VideoView component to show the video.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" >

<VideoView android:id="@+id/video_view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" />

</FrameLayout>

Page 9: Introduction to Android Internals_Omar_Ayed

Implementing the Activity Classes

try {

myVideoView.setMediaController(mediaControls);myVideoView.setVideoURI(Uri.parse("android.resource://com.android.lanucher2" +

"/"+ R.raw. java_breaking_bad));

} catch (Exception e) {

Log.e("Error", e.getMessage());e.printStackTrace();

}

Load the video from the res/raw folder to the VideoView and set the Media Controller buttons.

Page 10: Introduction to Android Internals_Omar_Ayed

Implementing the Activity Classes

myVideoView.requestFocus();myVideoView.setOnPreparedListener(new OnPreparedListener() {

public void onPrepared(MediaPlayer mp) {progressDialog.dismiss();myVideoView.seekTo(position);if (position == 0)

myVideoView.start(); // start the videoelse

myVideoView.pause(); // pause the video }});

// this listener even when the video completed playing myVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

public void onCompletion(MediaPlayer mp) {if (isLoop) // check if the video in loop mode

myVideoView.start();}});

Prepare the video to start from the zero seek , and check if isLoop true to play the video again in loop after is finish .

Page 11: Introduction to Android Internals_Omar_Ayed

@Overridepublic boolean onKeyDown(int keycode, KeyEvent e) {switch (keycode){case KeyEvent.KEYCODE_VOLUME_UP: {if (position < myVideoView.getDuration() - 4) {position += 4;myVideoView.seekTo(position);myVideoView.start();}return true;}case KeyEvent.KEYCODE_VOLUME_DOWN: {if (position > 4) {position -= 4;myVideoView.seekTo(position);myVideoView.start();}return true;}

Override the hardware buttonsWe have to override the hardware buttons to do another methods

case KeyEvent.KEYCODE_HOME: {

if (myVideoView.isPlaying()) {position = myVideoView.getCurrentPosition();myVideoView.pause();} else {myVideoView.seekTo(position);myVideoView.start();}return true;}case KeyEvent.KEYCODE_POWER:myVideoView.stopPlayback();return true;}

return super.onKeyDown(keycode, e);}

Page 12: Introduction to Android Internals_Omar_Ayed

Install and Run the Apk file Now create apk file using eclipse and install it in your device , then reboot your tablet/device and it should run in Auto-Boot Single application mode. It may prompt for default home option to select between “Launcher” and “Your Application”. Select your application and tick the checkbox to make it default selection.

Page 13: Introduction to Android Internals_Omar_Ayed

First you have to root your device before install the custom Rom. After that download the suit custom Rom for your device (you can to use Cyanogenmod Roms) from this link : http://download.cyanogenmod.org/?deviceAfter that exact the zip file that you downloaded . and you will get 3 files:

Second Method Custom Rom

Just open the system folder and delete all the unneeded files like media, font ,app ,pri-app … . Keep only the framework and etc. folders. Copy your application into app folder .

(Your app, apk file)

Page 14: Introduction to Android Internals_Omar_Ayed

Flash your custom RomNow archive the folder to zip folder and copy it to your device storage.

1. Reboot your phone into Recovery mode.

2. Head to the "Install" or "Install ZIP from SD Card" section of your recovery.

3. Navigate to the ZIP file you downloaded earlier, and select it from the list to flash it. Wait for the process to complete; it may take a few minutes.

4. You may also need to wipe your data and/or cache, you'll find this under the "Wipe" section, and in ClockworkMod, you'll need to either choose the "Wipe Data/Factory Reset" option or the "Wipe Cache Partition" option. When you're done, you're free to reboot into your new ROM , Only your app will run in background.

Page 15: Introduction to Android Internals_Omar_Ayed

First download the android source code (Android-X86) to start to work, or follow this tutorial :http://www.android-x86.org/getsourcecode

Third Method AOSP (Android Open Source Project)

Page 16: Introduction to Android Internals_Omar_Ayed

After the AOSP installing completed, we have to build a custom device rom ,for there download a ready custom device rom from this link : https://github.com/ronubo/AnDevCon_IVAlso below in same page the project, there is tutorial explain how to handle with the project.

The Project files :

Page 17: Introduction to Android Internals_Omar_Ayed

Also you can just rename every reference to "nubo" to a name of your own, and every reference to "desktop_generic" to a product name of your own.After the changes, put your project files in this path :Android\AOSP\device\YOUR_VENDER\YOUR_PROJECT

Page 18: Introduction to Android Internals_Omar_Ayed

Now delete all the apps in the project, form this Path: Your_vender\andevcon\system\app\ , and put your app instead these apps (because we need only one app running in this rom) and unnecessary files like media and fonts .

Your application package , (APK file)

Page 19: Introduction to Android Internals_Omar_Ayed

Build your project : Path your terminal in Linux OS to AOSP directory, and execute this commands:$ .build/envsetup.sh $ .lunch desktop_generic-eng //desktop_generic is your project name.$ . make -j8 iso_img //create an img file.

Your Custom device building

Page 20: Introduction to Android Internals_Omar_Ayed

Run your custom image in Emulator With the build completed, all you need to do is start the emulator to run your own : $ emulator &

To change the orientation Num 7

Page 21: Introduction to Android Internals_Omar_Ayed
Page 22: Introduction to Android Internals_Omar_Ayed

Application run in My Tablet. Link : https://www.youtube.com/watch?v=Jb5f74VMWxo&feature=youtu.be

The video that running in the application.Link : https://www.youtube.com/watch?v=DGa6MAibjzA


Recommended