android 2.2 apidemos 赏析笔记 6
SearchInvoke.java
传送门
这个。。。
这里只是一个调用GOOGLE的searchUI的一个范例,不是具体实现什么功能,和menu键一样,那个搜索键的相关功能设置
SEE:
1.
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
menu.removeItem(0);
menu.removeItem(1);
return true;
}
SO:
此函数可以动态的修改MENU菜单,onCreateOptionMenu不能动态修改?
SEE:
1.
Bundle appDataBundle = null;
final String queryAppDataString = mQueryAppData.getText().toString();
if (queryAppDataString != null) {
appDataBundle = new Bundle();
appDataBundle.putString("demo_key", queryAppDataString);
}
startSearch(queryPrefill, false, appDataBundle, false);
SO:
这样搜索UI调用结束。
SEE:
1.AndroidManifest.xml
<activity android:name=".app.SearchInvoke"
android:label="@string/search_invoke">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
<meta-data android:name="android.app.default_searchable"
android:value=".app.SearchQueryResults" />
</activity>
2.
<activity android:name=".app.SearchQueryResults"
android:label="@string/search_query_results">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<provider android:name=".app.SearchSuggestionSampleProvider"
android:authorities="com.example.android.apis.SuggestionProvider" />
3.
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_label"
android:hint="@string/search_hint"
android:searchMode="showSearchLabelAsBadge"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
android:voiceLanguageModel="free_form"
android:voicePromptText="@string/search_invoke"
android:searchSuggestAuthority="com.example.android.apis.SuggestionProvider"
android:searchSuggestSelection=" ? "
/>
SO:
1.meta-data 变化的数据,来设定响应的activity
2.设定resource 和
3.设定某些东西,我关注的是android:searchSuggestAuthorit="com.example.android.apis.SuggestionProvider"
SEE:SearchQueryResults.JAVA
1.
final Intent queryIntent = getIntent();
final String queryAction = queryIntent.getAction();
if (Intent.ACTION_SEARCH.equals(queryAction)) {
doSearchQuery(queryIntent, "onCreate()");
}
else {
mDeliveredByText.setText("onCreate(), but no ACTION_SEARCH intent");
}
2.
private void doSearchQuery(final Intent queryIntent, final String entryPoint) {
final String queryString = queryIntent.getStringExtra(SearchManager.QUERY);
mQueryText.setText(queryString);
3.
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
SearchSuggestionSampleProvider.AUTHORITY, SearchSuggestionSampleProvider.MODE);
suggestions.saveRecentQuery(queryString, null);
4.
final Bundle appData = queryIntent.getBundleExtra(SearchManager.APP_DATA);
if (appData == null) {
mAppDataText.setText("<no app data bundle>");
}
if (appData != null) {
String testStr = appData.getString("demo_key");
mAppDataText.setText((testStr == null) ? "<no app data>" : testStr);
}
5.
public void onNewIntent(final Intent newIntent) {
super.onNewIntent(newIntent);
// get and process search query here
final Intent queryIntent = getIntent();
final String queryAction = queryIntent.getAction();
if (Intent.ACTION_SEARCH.equals(queryAction)) {
doSearchQuery(queryIntent, "onNewIntent()");
}
else {
mDeliveredByText.setText("onNewIntent(), but no ACTION_SEARCH intent");
}
}
SO:
1.
判断启动该ACTIVITY的INTENT的ACTION,判断是由搜索启动的还是直接启动的
2.
获得第一个默认的字符串 startSearch(queryPrefill, false, appDataBundle, false);
3
获得指定的suggestion,参数为,this,名字,模式。保存该搜索。
4.
获取附加的数据,key为"demo_key"
5.
当activity已经打开的时候,接受到新的INTENT重启的时候调用的方法。
SEE:
1.SearchSuggestionSampleProvider .java
public class SearchSuggestionSampleProvider extends SearchRecentSuggestionsProvider {
final static String AUTHORITY = "com.example.android.apis.SuggestionProvider";
final static int MODE = DATABASE_MODE_QUERIES;
public SearchSuggestionSampleProvider() {
super();
setupSuggestions(AUTHORITY, MODE);
}
}
SO:
setupSuggestions(AUTHORITY, MODE);创建相应名字,模式的suggestion以供调用吧
ForegroundService.java
SEE:
1.
<service android:name=".app.ForegroundService" />
<activity android:name=".app.ForegroundService$Controller"
android:label="@string/activity_foreground_service_controller"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
2.
ForegroundService$Controller
SO:
使用内部类的ACTIVITY 第二次。这真奇怪为SERVICE服务的 ACTIVITY
SEE:
1.
Intent intent = new Intent(ForegroundService.ACTION_FOREGROUND);
intent.setClass(Controller.this, ForegroundService.class);
startService(intent);
2.
Intent intent = new Intent(ForegroundService.ACTION_BACKGROUND);
intent.setClass(Controller.this, ForegroundService.class);
startService(intent);
3.
stopService(new Intent(Controller.this,
ForegroundService.class));
SO:
开始service和结束Service都用的Intent
SEE:
1.
public void onStart(Intent intent, int startId) {
handleCommand(intent);
}
2.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
handleCommand(intent);
// We want this service to continue running until it is explicitly
// stopped, so return sticky.
return START_STICKY;
}
3.
void handleCommand(Intent intent) {
if (ACTION_FOREGROUND.equals(intent.getAction())) {
// In this sample, we'll use the same text for the ticker and the expanded notification
CharSequence text = getText(R.string.foreground_service_started);
// Set the icon, scrolling text and timestamp
Notification notification = new Notification(R.drawable.stat_sample, text,
System.currentTimeMillis());
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, Controller.class), 0);
// Set the info for the views that show in the notification panel.
notification.setLatestEventInfo(this, getText(R.string.local_service_label),
text, contentIntent);
startForegroundCompat(R.string.foreground_service_started, notification);
} else if (ACTION_BACKGROUND.equals(intent.getAction())) {
stopForegroundCompat(R.string.foreground_service_started);
}
}
SO:
1.startService会调用onStart
2.onStartCommand,我们希望这个Service持续运行,直到明确的停止,所以应返回一个stricky
3.
设置一个notification和一个id,通过某种方式来启动notification
SEE:
private static final Class[] mStartForegroundSignature = new Class[] {
int.class, Notification.class};
private static final Class[] mStopForegroundSignature = new Class[] {
boolean.class};
private Method mStartForeground;
private Method mStopForeground;
private Object[] mStartForegroundArgs = new Object[2];
private Object[] mStopForegroundArgs = new Object[1];
1.
try {
mStartForeground = getClass().getMethod("startForeground",
mStartForegroundSignature);
mStopForeground = getClass().getMethod("stopForeground",
mStopForegroundSignature);
} catch (NoSuchMethodException e) {
// Running on an older platform.
mStartForeground = mStopForeground = null;
}
2.
if (mStartForeground != null) {
mStartForegroundArgs[0] = Integer.valueOf(id);
mStartForegroundArgs[1] = notification;
try {
mStartForeground.invoke(this, mStartForegroundArgs);
} catch (InvocationTargetException e) {
// Should not happen.
Log.w("ApiDemos", "Unable to invoke startForeground", e);
} catch (IllegalAccessException e) {
// Should not happen.
Log.w("ApiDemos", "Unable to invoke startForeground", e);
}
return;
}
// Fall back on the old API.
setForeground(true);
mNM.notify(id, notification);
3.
mNM.cancel(id);
setForeground(false);
SO:
1.
getClass().getMethod(),通过名字与特征参数来获取该类的某个方法。startForeground() 有可能存在或者不存在。我们希望优先调用service提供的startForeground()。通过 Method 保持引用。
2.
mStartForeground.invoke(this, mStartForegroundArgs);调用方法。如果不存在在使用自己的NM
3.
后台运行自行设置的方法,这里应该是走的是SERVICE的stopForeground
LocalServiceActivities.java
SEE:LocalServiceActivities$LocalServiceActivities
1.
bindService(new Intent(Binding.this,
LocalService.class), mConnection, Context.BIND_AUTO_CREATE);
2.
unbindService(mConnection);
3.
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
mBoundService = ((LocalService.LocalBinder)service).getService();
Toast.makeText(Binding.this, R.string.local_service_connected,
Toast.LENGTH_SHORT).show();
}
public void onServiceDisconnected(ComponentName className) {
mBoundService = null;
Toast.makeText(Binding.this, R.string.local_service_disconnected,
Toast.LENGTH_SHORT).show();
}
};
SO:
1.绑定服务
2.取消服务
3.应该算是一个监听吧 外带Context.BIND_AUTO_CREATE
SEE:LocalServiceActivities$Controller
1.
startService(new Intent(Controller.this,
LocalService.class));
2.
stopService(new Intent(Controller.this,
LocalService.class));
SO:
额,startService Activity退出的时候 Service不中断, bindService Activity退出的时候Service一起中断。完毕。懒的要死。两个放在一起做内部类。虽然可以对比
MessengerServiceActivities.java
SEE:
private ServiceConnection mConnection = new ServiceConnection() {
1.
bindService(new Intent(Binding.this,
MessengerService.class), mConnection, Context.BIND_AUTO_CREATE);
2.
unbindService(mConnection);
SO:
绑定MessengerService,和取消MessengerService。复习
SEE:
1.
class IncomingHandler extends Handler {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MessengerService.MSG_SET_VALUE:
mCallbackText.setText("Received from service: " + msg.arg1);
break;
default:
super.handleMessage(msg);
}
}
}
2.
final Messenger mMessenger = new Messenger(new IncomingHandler());
3.
mService = new Messenger(service);
Message msg = Message.obtain(null,
MessengerService.MSG_REGISTER_CLIENT);
msg.replyTo = mMessenger;
mService.send(msg);
4.
msg = Message.obtain(null,
MessengerService.MSG_SET_VALUE, this.hashCode(), 0);
mService.send(msg);
SO:
1.
获得输入的句柄。handler
2.
Create a new Messenger pointing to the given Handler. Any Message objects sent through this Messenger will appear in the Handler as if Handler.sendMessage(Message) had been called directly.
也就是说 使用该Messenger等同于想Handler.sendMessage()
3.
同绑定一个Handler一样绑定一个IBander,这里的IBander应该是MessengerService。
由于已经有绑定的, Message.obtain(Handler,int)这里的Handler设为NULL。然后通过mService.send()就好。
4.
同3这里多指定了一些东西。
SEE:MessengerService.JAVA
ArrayList<Messenger> mClients = new ArrayList<Messenger>();
1.
class IncomingHandler extends Handler {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_REGISTER_CLIENT:
mClients.add(msg.replyTo);
break;
case MSG_UNREGISTER_CLIENT:
mClients.remove(msg.replyTo);
break;
case MSG_SET_VALUE:
mValue = msg.arg1;
for (int i=mClients.size()-1; i>=0; i--) {
try {
mClients.get(i).send(Message.obtain(null,
MSG_SET_VALUE, mValue, 0));
} catch (RemoteException e) {
// The client is dead. Remove it from the list;
// we are going through the list from back to front
// so this is safe to do inside the loop.
mClients.remove(i);
}
}
break;
default:
super.handleMessage(msg);
}
}
}
SO:
1.这里负责响应上一块发送的消息。
2.保存msg带来的replyTo
3.收到消息的时候,逐一对mClients进行发送消息。
4.注意到里面有个mClients.remove的动作。由于是由后向前的一个遍历,不会导致删除后,size变化,而出错。
RemoteService.java
SEE:RemoteService$Binding
1.
bindService(new Intent(IRemoteService.class.getName()),
mConnection, Context.BIND_AUTO_CREATE);
bindService(new Intent(ISecondary.class.getName()),
mSecondaryConnection, Context.BIND_AUTO_CREATE);
2.IRemoteService.java
* This file is auto-generated. DO NOT MODIFY.
3.
<service android:name=".app.RemoteService" android:process=":remote">
<intent-filter>
<!-- These are the interfaces supported by the service, which
you can bind to. -->
<action android:name="com.example.android.apis.app.IRemoteService" />
<action android:name="com.example.android.apis.app.ISecondary" />
<!-- This is an action code you can use to select the service
without explicitly supplying the implementation class. -->
<action android:name="com.example.android.apis.app.REMOTE_SERVICE" />
</intent-filter>
</service>
SO:
1.这是一个AIDL的范例。这里的intent(getname())=intent("com.example.android.apis.app.IRemoteService"),指其支持的某一个接口,
2.
IRemoteService是由ADT自动根据IRemoteService.aidl自动生成的
3.
这个服务允许绑定的几个接口。这几个接口的Intent绑定的实际上都是这个service。
SEE:RemoteService$Binding
1.
mService = IRemoteService.Stub.asInterface(service);
2.
mService.registerCallback(mCallback);
3.
private IRemoteServiceCallback mCallback = new IRemoteServiceCallback.Stub() {
public void valueChanged(int value) {
mHandler.sendMessage(mHandler.obtainMessage(BUMP_MSG, value, 0));
}
};
4.
private Handler mHandler = new Handler() {
@Override public void handleMessage(Message msg) {
switch (msg.what) {
case BUMP_MSG:
mCallbackText.setText("Received from service: " + msg.arg1);
break;
default:
super.handleMessage(msg);
}
}
};
SO:
1.这里的接口实例,是自动生成的
2.注册CALLBACK
3.new以个重写过valueChanged()的callback
4.Activity主进程的Handler,用来更新组件
SEE:RemoteService$Binding
1.
mSecondaryService = ISecondary.Stub.asInterface(service);
SO:
同上
解释
建立AIDL服务要比建立普通的服务复杂一些,具体步骤如下:
(1)在Eclipse Android工程的Java包目录中建立一个扩展名为aidl的文件。该文件的语法类似于Java代码,但会稍有不同。详细介绍见实例的内容。
(2)如果aidl文件的内容是正确的,ADT会自动生成一个Java接口文件(*.java)。
(3)建立一个服务类(Service的子类)。
(4)实现由aidl文件生成的Java接口。
(5)在AndroidManifest.xml文件中配置AIDL服务,尤其要注意的是,<action>标签中android:name的属性值就是客户端要引用该服务的ID,也就是Intent类的参数值。
SEE com.example.android.apis.app.xxxx.aidl
1.
interface IRemoteService {
/**
* Often you want to allow a service to call back to its clients.
* This shows how to do so, by registering a callback interface with
* the service.
*/
void registerCallback(IRemoteServiceCallback cb);
/**
* Remove a previously registered callback interface.
*/
void unregisterCallback(IRemoteServiceCallback cb);
}
2.
oneway interface IRemoteServiceCallback {
/**
* Called when the service has a new value for you.
*/
void valueChanged(int value);
}
3.
interface ISecondary {
/**
* Request the PID of this service, to do evil things with it.
*/
int getPid();
/**
* This demonstrates the basic types that you can use as parameters
* and return values in AIDL.
*/
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
double aDouble, String aString);
}
SO;
AIDL:Android Interface Definition Language,即Android接口描述语言。Android系统中的进程之间不能共享内存,因此,需要提供一些机制在不同进程之间进行数据通信。
1.这里定义了两个接口,其具体的实现在 RemoteService 中,这里只是提供封装好的接口,虽然是两个不同的接口,但实现的地方去是在同一个地方。接口的作用。所以当KILLPROCESS的时候KILL的是同一个PROCESS。。
2.oneway 表示服务将不会中断来等待客户响应。
3.两个方法。一个貌似没用。
SEE:RemoteService.java
0.
final RemoteCallbackList<IRemoteServiceCallback> mCallbacks
= new RemoteCallbackList<IRemoteServiceCallback>();
1.
mHandler.sendEmptyMessage(REPORT_MSG);
2.
private final Handler mHandler = new Handler() {
@Override public void handleMessage(Message msg) {
switch (msg.what) {
// It is time to bump the value!
case REPORT_MSG: {
// Up it goes.
int value = ++mValue;
// Broadcast to all clients the new value.
final int N = mCallbacks.beginBroadcast();
for (int i=0; i<N; i++) {
try {
mCallbacks.getBroadcastItem(i).valueChanged(value);
} catch (RemoteException e) {
// The RemoteCallbackList will take care of removing
// the dead object for us.
}
}
mCallbacks.finishBroadcast();
// Repeat every 1 second.
sendMessageDelayed(obtainMessage(REPORT_MSG), 1*1000);
} break;
default:
super.handleMessage(msg);
}
}
};
SO:
0.
RemoteCallbackList
1.
sendEmptyMessage() Sends a Message containing only the what value.
2.
这就是数字递增的地方。。,和broadcast的地方。
SEE:
总结
SO:
1.写好aidl文件,然后由ADT进行自动创建JAVA文件。
2.在AndroidManifest.xml中注册某个service为响应其ACTION。
3.在SERVICE中实现接口定义的方法。
4.在客户端中调用响应的接口来进行操作,而不需要知道具体由哪个SERVICE实现的。。
5.完。。这个东西省到极点了,像解迷一样。。如果你弄懂了,恭喜解谜成功。
SEE: RemoteService.Controller.JAVA
1.
startService(new Intent(
"com.example.android.apis.app.REMOTE_SERVICE"));
2.AndroidManifest.xml
直接启动 <action android:name="com.example.android.apis.app.REMOTE_SERVICE" />
SO:
直接启动SERVICE,进行notification的显示,无其他功能。
SO EASY。
ServiceStartArguments.java
SEE:
1.
HandlerThread thread = new HandlerThread("ServiceStartArguments",
Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
mServiceLooper = thread.getLooper();
mServiceHandler = new ServiceHandler(mServiceLooper);
SO:
1.
创建一个线程,开始,取得Looper(),通过Looper创建Handler,并实现其hendlerMessage的方法
SEE:
1.
// We show this for as long as our service is processing a command.
notification.flags |= Notification.FLAG_ONGOING_EVENT;
SO:
当service在处理command的时候notification存在。
SEE:正常路线
1.
startService(new Intent(Controller.this,
ServiceStartArguments.class)
.putExtra("name", "One"));
2.
public int onStartCommand(Intent intent, int flags, int startId) {
Message msg = mServiceHandler.obtainMessage();
msg.arg1 = startId;
msg.arg2 = flags;
msg.obj = intent.getExtras();
mServiceHandler.sendMessage(msg);
3.
public void handleMessage(Message msg) {
Bundle arguments = (Bundle)msg.obj;
String txt = arguments.getString("name");
Log.i("ServiceStartArguments", "Message: " + msg + ", "
+ arguments.getString("name"));
if ((msg.arg2&Service.START_FLAG_REDELIVERY) == 0) {
txt = "New cmd #" + msg.arg1 + ": " + txt;
} else {
txt = "Re-delivered #" + msg.arg1 + ": " + txt;
}
showNotification(txt);
4.
long endTime = System.currentTimeMillis() + 5*1000;
while (System.currentTimeMillis() < endTime) {
synchronized (this) {
try {
wait(endTime - System.currentTimeMillis());
} catch (Exception e) {
}
}
}
hideNotification();
Log.i("ServiceStartArguments", "Done with #" + msg.arg1);
stopSelf(msg.arg1);
}
5.
public void onDestroy() {
mServiceLooper.quit();
hideNotification();
// Tell the user we stopped.
Toast.makeText(ServiceStartArguments.this, R.string.service_destroyed,
Toast.LENGTH_SHORT).show();
}
SO:
1.
启动SERVICE
2.
将启动时的状态,发送给HANDLER处理
3.
当flag为Service.START_FLAG_REDELIVERY的时候做不同的处理
4.
等待5秒,关掉NOTIFICATION.
5.
接下来继续处理其他的MESSAGE,所以每一个NOTIFICATION将持续五秒。直到所有的MESSAGE处理完了,调用HANDLER的onDestory方法,这是显示 service destory 的 toast
SEE:不正常路线 FAIL
1.
private OnClickListener mStartFailListener = new OnClickListener() {
public void onClick(View v) {
startService(new Intent(Controller.this,
ServiceStartArguments.class)
.putExtra("name", "Failure")
.putExtra("fail", true));
}
};
2.
// For the start fail button, we will simulate the process dying
// for some reason in onStartCommand().
if (intent.getBooleanExtra("fail", false)) {
// Don't do this if we are in a retry... the system will
// eventually give up if we keep crashing.
if ((flags&START_FLAG_RETRY) == 0) {
// Since the process hasn't finished handling the command,
// it will be restarted with the command again, regardless of
// whether we return START_REDELIVER_INTENT.
Process.killProcess(Process.myPid());
}
}
3.
点击 start failed delivery 并等待
SO:
1.
启动service
2.
第一次启动服务的时候,flag肯定不是START_FLAG_RETRY,所以killProcess。
3.
killProcess后 service自动重启。这时的FLAG为START_FLAG_RETRY 所以正常显示NOTIFICATION
SEE:不正常路线 redeliver
1.
startService(new Intent(Controller.this,
ServiceStartArguments.class)
.putExtra("name", "Three")
.putExtra("redeliver", true));
2.
return intent.getBooleanExtra("redeliver", false)
? START_REDELIVER_INTENT : START_NOT_STICKY;
3.
点击 start three 并观察
4.
再次点击 start three 在 service destoryed之前点击 kill Process,并观察
SO:
1.
设置相关配置,开始service
2.
返回 START_REDELIVER_INTENT 表示需要当service 意外终止时重新发送 intent
3.
没有意外终止,显示new command
4.
意外终止,显示re_delivered,表明,该SERVICE重启,并重新接受INTENT
TextToSpeechActivity.java
SEE:
1.
mTts = new TextToSpeech(this,this // TextToSpeech.OnInitListener
);
2.
// Implements TextToSpeech.OnInitListener.
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = mTts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA ||
result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e(TAG, "Language is not available.");
} else {
mAgainButton.setEnabled(true);
}
} else {
Log.e(TAG, "Could not initialize TextToSpeech.");
}
}
3.
mTts.speak(hello,
TextToSpeech.QUEUE_FLUSH, // Drop all pending entries in the playback queue.
null);
SO:
1.创建实例
2.监听初始化
3.说话。。
VoiceRecognition.java
无法测试。。
====================================APP完~ 好像解密游戏呀
传送门
这个。。。
这里只是一个调用GOOGLE的searchUI的一个范例,不是具体实现什么功能,和menu键一样,那个搜索键的相关功能设置
SEE:
1.
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
menu.removeItem(0);
menu.removeItem(1);
return true;
}
SO:
此函数可以动态的修改MENU菜单,onCreateOptionMenu不能动态修改?
SEE:
1.
Bundle appDataBundle = null;
final String queryAppDataString = mQueryAppData.getText().toString();
if (queryAppDataString != null) {
appDataBundle = new Bundle();
appDataBundle.putString("demo_key", queryAppDataString);
}
startSearch(queryPrefill, false, appDataBundle, false);
SO:
这样搜索UI调用结束。
SEE:
1.AndroidManifest.xml
<activity android:name=".app.SearchInvoke"
android:label="@string/search_invoke">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
<meta-data android:name="android.app.default_searchable"
android:value=".app.SearchQueryResults" />
</activity>
2.
<activity android:name=".app.SearchQueryResults"
android:label="@string/search_query_results">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<provider android:name=".app.SearchSuggestionSampleProvider"
android:authorities="com.example.android.apis.SuggestionProvider" />
3.
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_label"
android:hint="@string/search_hint"
android:searchMode="showSearchLabelAsBadge"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
android:voiceLanguageModel="free_form"
android:voicePromptText="@string/search_invoke"
android:searchSuggestAuthority="com.example.android.apis.SuggestionProvider"
android:searchSuggestSelection=" ? "
/>
SO:
1.meta-data 变化的数据,来设定响应的activity
2.设定resource 和
3.设定某些东西,我关注的是android:searchSuggestAuthorit="com.example.android.apis.SuggestionProvider"
SEE:SearchQueryResults.JAVA
1.
final Intent queryIntent = getIntent();
final String queryAction = queryIntent.getAction();
if (Intent.ACTION_SEARCH.equals(queryAction)) {
doSearchQuery(queryIntent, "onCreate()");
}
else {
mDeliveredByText.setText("onCreate(), but no ACTION_SEARCH intent");
}
2.
private void doSearchQuery(final Intent queryIntent, final String entryPoint) {
final String queryString = queryIntent.getStringExtra(SearchManager.QUERY);
mQueryText.setText(queryString);
3.
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
SearchSuggestionSampleProvider.AUTHORITY, SearchSuggestionSampleProvider.MODE);
suggestions.saveRecentQuery(queryString, null);
4.
final Bundle appData = queryIntent.getBundleExtra(SearchManager.APP_DATA);
if (appData == null) {
mAppDataText.setText("<no app data bundle>");
}
if (appData != null) {
String testStr = appData.getString("demo_key");
mAppDataText.setText((testStr == null) ? "<no app data>" : testStr);
}
5.
public void onNewIntent(final Intent newIntent) {
super.onNewIntent(newIntent);
// get and process search query here
final Intent queryIntent = getIntent();
final String queryAction = queryIntent.getAction();
if (Intent.ACTION_SEARCH.equals(queryAction)) {
doSearchQuery(queryIntent, "onNewIntent()");
}
else {
mDeliveredByText.setText("onNewIntent(), but no ACTION_SEARCH intent");
}
}
SO:
1.
判断启动该ACTIVITY的INTENT的ACTION,判断是由搜索启动的还是直接启动的
2.
获得第一个默认的字符串 startSearch(queryPrefill, false, appDataBundle, false);
3
获得指定的suggestion,参数为,this,名字,模式。保存该搜索。
4.
获取附加的数据,key为"demo_key"
5.
当activity已经打开的时候,接受到新的INTENT重启的时候调用的方法。
SEE:
1.SearchSuggestionSampleProvider .java
public class SearchSuggestionSampleProvider extends SearchRecentSuggestionsProvider {
final static String AUTHORITY = "com.example.android.apis.SuggestionProvider";
final static int MODE = DATABASE_MODE_QUERIES;
public SearchSuggestionSampleProvider() {
super();
setupSuggestions(AUTHORITY, MODE);
}
}
SO:
setupSuggestions(AUTHORITY, MODE);创建相应名字,模式的suggestion以供调用吧
ForegroundService.java
SEE:
1.
<service android:name=".app.ForegroundService" />
<activity android:name=".app.ForegroundService$Controller"
android:label="@string/activity_foreground_service_controller"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
2.
ForegroundService$Controller
SO:
使用内部类的ACTIVITY 第二次。这真奇怪为SERVICE服务的 ACTIVITY
SEE:
1.
Intent intent = new Intent(ForegroundService.ACTION_FOREGROUND);
intent.setClass(Controller.this, ForegroundService.class);
startService(intent);
2.
Intent intent = new Intent(ForegroundService.ACTION_BACKGROUND);
intent.setClass(Controller.this, ForegroundService.class);
startService(intent);
3.
stopService(new Intent(Controller.this,
ForegroundService.class));
SO:
开始service和结束Service都用的Intent
SEE:
1.
public void onStart(Intent intent, int startId) {
handleCommand(intent);
}
2.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
handleCommand(intent);
// We want this service to continue running until it is explicitly
// stopped, so return sticky.
return START_STICKY;
}
3.
void handleCommand(Intent intent) {
if (ACTION_FOREGROUND.equals(intent.getAction())) {
// In this sample, we'll use the same text for the ticker and the expanded notification
CharSequence text = getText(R.string.foreground_service_started);
// Set the icon, scrolling text and timestamp
Notification notification = new Notification(R.drawable.stat_sample, text,
System.currentTimeMillis());
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, Controller.class), 0);
// Set the info for the views that show in the notification panel.
notification.setLatestEventInfo(this, getText(R.string.local_service_label),
text, contentIntent);
startForegroundCompat(R.string.foreground_service_started, notification);
} else if (ACTION_BACKGROUND.equals(intent.getAction())) {
stopForegroundCompat(R.string.foreground_service_started);
}
}
SO:
1.startService会调用onStart
2.onStartCommand,我们希望这个Service持续运行,直到明确的停止,所以应返回一个stricky
3.
设置一个notification和一个id,通过某种方式来启动notification
SEE:
private static final Class[] mStartForegroundSignature = new Class[] {
int.class, Notification.class};
private static final Class[] mStopForegroundSignature = new Class[] {
boolean.class};
private Method mStartForeground;
private Method mStopForeground;
private Object[] mStartForegroundArgs = new Object[2];
private Object[] mStopForegroundArgs = new Object[1];
1.
try {
mStartForeground = getClass().getMethod("startForeground",
mStartForegroundSignature);
mStopForeground = getClass().getMethod("stopForeground",
mStopForegroundSignature);
} catch (NoSuchMethodException e) {
// Running on an older platform.
mStartForeground = mStopForeground = null;
}
2.
if (mStartForeground != null) {
mStartForegroundArgs[0] = Integer.valueOf(id);
mStartForegroundArgs[1] = notification;
try {
mStartForeground.invoke(this, mStartForegroundArgs);
} catch (InvocationTargetException e) {
// Should not happen.
Log.w("ApiDemos", "Unable to invoke startForeground", e);
} catch (IllegalAccessException e) {
// Should not happen.
Log.w("ApiDemos", "Unable to invoke startForeground", e);
}
return;
}
// Fall back on the old API.
setForeground(true);
mNM.notify(id, notification);
3.
mNM.cancel(id);
setForeground(false);
SO:
1.
getClass().getMethod(),通过名字与特征参数来获取该类的某个方法。startForeground() 有可能存在或者不存在。我们希望优先调用service提供的startForeground()。通过 Method 保持引用。
2.
mStartForeground.invoke(this, mStartForegroundArgs);调用方法。如果不存在在使用自己的NM
3.
后台运行自行设置的方法,这里应该是走的是SERVICE的stopForeground
LocalServiceActivities.java
SEE:LocalServiceActivities$LocalServiceActivities
1.
bindService(new Intent(Binding.this,
LocalService.class), mConnection, Context.BIND_AUTO_CREATE);
2.
unbindService(mConnection);
3.
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
mBoundService = ((LocalService.LocalBinder)service).getService();
Toast.makeText(Binding.this, R.string.local_service_connected,
Toast.LENGTH_SHORT).show();
}
public void onServiceDisconnected(ComponentName className) {
mBoundService = null;
Toast.makeText(Binding.this, R.string.local_service_disconnected,
Toast.LENGTH_SHORT).show();
}
};
SO:
1.绑定服务
2.取消服务
3.应该算是一个监听吧 外带Context.BIND_AUTO_CREATE
SEE:LocalServiceActivities$Controller
1.
startService(new Intent(Controller.this,
LocalService.class));
2.
stopService(new Intent(Controller.this,
LocalService.class));
SO:
额,startService Activity退出的时候 Service不中断, bindService Activity退出的时候Service一起中断。完毕。懒的要死。两个放在一起做内部类。虽然可以对比
MessengerServiceActivities.java
SEE:
private ServiceConnection mConnection = new ServiceConnection() {
1.
bindService(new Intent(Binding.this,
MessengerService.class), mConnection, Context.BIND_AUTO_CREATE);
2.
unbindService(mConnection);
SO:
绑定MessengerService,和取消MessengerService。复习
SEE:
1.
class IncomingHandler extends Handler {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MessengerService.MSG_SET_VALUE:
mCallbackText.setText("Received from service: " + msg.arg1);
break;
default:
super.handleMessage(msg);
}
}
}
2.
final Messenger mMessenger = new Messenger(new IncomingHandler());
3.
mService = new Messenger(service);
Message msg = Message.obtain(null,
MessengerService.MSG_REGISTER_CLIENT);
msg.replyTo = mMessenger;
mService.send(msg);
4.
msg = Message.obtain(null,
MessengerService.MSG_SET_VALUE, this.hashCode(), 0);
mService.send(msg);
SO:
1.
获得输入的句柄。handler
2.
Create a new Messenger pointing to the given Handler. Any Message objects sent through this Messenger will appear in the Handler as if Handler.sendMessage(Message) had been called directly.
也就是说 使用该Messenger等同于想Handler.sendMessage()
3.
同绑定一个Handler一样绑定一个IBander,这里的IBander应该是MessengerService。
由于已经有绑定的, Message.obtain(Handler,int)这里的Handler设为NULL。然后通过mService.send()就好。
4.
同3这里多指定了一些东西。
SEE:MessengerService.JAVA
ArrayList<Messenger> mClients = new ArrayList<Messenger>();
1.
class IncomingHandler extends Handler {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_REGISTER_CLIENT:
mClients.add(msg.replyTo);
break;
case MSG_UNREGISTER_CLIENT:
mClients.remove(msg.replyTo);
break;
case MSG_SET_VALUE:
mValue = msg.arg1;
for (int i=mClients.size()-1; i>=0; i--) {
try {
mClients.get(i).send(Message.obtain(null,
MSG_SET_VALUE, mValue, 0));
} catch (RemoteException e) {
// The client is dead. Remove it from the list;
// we are going through the list from back to front
// so this is safe to do inside the loop.
mClients.remove(i);
}
}
break;
default:
super.handleMessage(msg);
}
}
}
SO:
1.这里负责响应上一块发送的消息。
2.保存msg带来的replyTo
3.收到消息的时候,逐一对mClients进行发送消息。
4.注意到里面有个mClients.remove的动作。由于是由后向前的一个遍历,不会导致删除后,size变化,而出错。
RemoteService.java
SEE:RemoteService$Binding
1.
bindService(new Intent(IRemoteService.class.getName()),
mConnection, Context.BIND_AUTO_CREATE);
bindService(new Intent(ISecondary.class.getName()),
mSecondaryConnection, Context.BIND_AUTO_CREATE);
2.IRemoteService.java
* This file is auto-generated. DO NOT MODIFY.
3.
<service android:name=".app.RemoteService" android:process=":remote">
<intent-filter>
<!-- These are the interfaces supported by the service, which
you can bind to. -->
<action android:name="com.example.android.apis.app.IRemoteService" />
<action android:name="com.example.android.apis.app.ISecondary" />
<!-- This is an action code you can use to select the service
without explicitly supplying the implementation class. -->
<action android:name="com.example.android.apis.app.REMOTE_SERVICE" />
</intent-filter>
</service>
SO:
1.这是一个AIDL的范例。这里的intent(getname())=intent("com.example.android.apis.app.IRemoteService"),指其支持的某一个接口,
2.
IRemoteService是由ADT自动根据IRemoteService.aidl自动生成的
3.
这个服务允许绑定的几个接口。这几个接口的Intent绑定的实际上都是这个service。
SEE:RemoteService$Binding
1.
mService = IRemoteService.Stub.asInterface(service);
2.
mService.registerCallback(mCallback);
3.
private IRemoteServiceCallback mCallback = new IRemoteServiceCallback.Stub() {
public void valueChanged(int value) {
mHandler.sendMessage(mHandler.obtainMessage(BUMP_MSG, value, 0));
}
};
4.
private Handler mHandler = new Handler() {
@Override public void handleMessage(Message msg) {
switch (msg.what) {
case BUMP_MSG:
mCallbackText.setText("Received from service: " + msg.arg1);
break;
default:
super.handleMessage(msg);
}
}
};
SO:
1.这里的接口实例,是自动生成的
2.注册CALLBACK
3.new以个重写过valueChanged()的callback
4.Activity主进程的Handler,用来更新组件
SEE:RemoteService$Binding
1.
mSecondaryService = ISecondary.Stub.asInterface(service);
SO:
同上
解释
建立AIDL服务要比建立普通的服务复杂一些,具体步骤如下:
(1)在Eclipse Android工程的Java包目录中建立一个扩展名为aidl的文件。该文件的语法类似于Java代码,但会稍有不同。详细介绍见实例的内容。
(2)如果aidl文件的内容是正确的,ADT会自动生成一个Java接口文件(*.java)。
(3)建立一个服务类(Service的子类)。
(4)实现由aidl文件生成的Java接口。
(5)在AndroidManifest.xml文件中配置AIDL服务,尤其要注意的是,<action>标签中android:name的属性值就是客户端要引用该服务的ID,也就是Intent类的参数值。
SEE com.example.android.apis.app.xxxx.aidl
1.
interface IRemoteService {
/**
* Often you want to allow a service to call back to its clients.
* This shows how to do so, by registering a callback interface with
* the service.
*/
void registerCallback(IRemoteServiceCallback cb);
/**
* Remove a previously registered callback interface.
*/
void unregisterCallback(IRemoteServiceCallback cb);
}
2.
oneway interface IRemoteServiceCallback {
/**
* Called when the service has a new value for you.
*/
void valueChanged(int value);
}
3.
interface ISecondary {
/**
* Request the PID of this service, to do evil things with it.
*/
int getPid();
/**
* This demonstrates the basic types that you can use as parameters
* and return values in AIDL.
*/
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
double aDouble, String aString);
}
SO;
AIDL:Android Interface Definition Language,即Android接口描述语言。Android系统中的进程之间不能共享内存,因此,需要提供一些机制在不同进程之间进行数据通信。
1.这里定义了两个接口,其具体的实现在 RemoteService 中,这里只是提供封装好的接口,虽然是两个不同的接口,但实现的地方去是在同一个地方。接口的作用。所以当KILLPROCESS的时候KILL的是同一个PROCESS。。
2.oneway 表示服务将不会中断来等待客户响应。
3.两个方法。一个貌似没用。
SEE:RemoteService.java
0.
final RemoteCallbackList<IRemoteServiceCallback> mCallbacks
= new RemoteCallbackList<IRemoteServiceCallback>();
1.
mHandler.sendEmptyMessage(REPORT_MSG);
2.
private final Handler mHandler = new Handler() {
@Override public void handleMessage(Message msg) {
switch (msg.what) {
// It is time to bump the value!
case REPORT_MSG: {
// Up it goes.
int value = ++mValue;
// Broadcast to all clients the new value.
final int N = mCallbacks.beginBroadcast();
for (int i=0; i<N; i++) {
try {
mCallbacks.getBroadcastItem(i).valueChanged(value);
} catch (RemoteException e) {
// The RemoteCallbackList will take care of removing
// the dead object for us.
}
}
mCallbacks.finishBroadcast();
// Repeat every 1 second.
sendMessageDelayed(obtainMessage(REPORT_MSG), 1*1000);
} break;
default:
super.handleMessage(msg);
}
}
};
SO:
0.
RemoteCallbackList
1.
sendEmptyMessage() Sends a Message containing only the what value.
2.
这就是数字递增的地方。。,和broadcast的地方。
SEE:
总结
SO:
1.写好aidl文件,然后由ADT进行自动创建JAVA文件。
2.在AndroidManifest.xml中注册某个service为响应其ACTION。
3.在SERVICE中实现接口定义的方法。
4.在客户端中调用响应的接口来进行操作,而不需要知道具体由哪个SERVICE实现的。。
5.完。。这个东西省到极点了,像解迷一样。。如果你弄懂了,恭喜解谜成功。
SEE: RemoteService.Controller.JAVA
1.
startService(new Intent(
"com.example.android.apis.app.REMOTE_SERVICE"));
2.AndroidManifest.xml
直接启动 <action android:name="com.example.android.apis.app.REMOTE_SERVICE" />
SO:
直接启动SERVICE,进行notification的显示,无其他功能。
SO EASY。
ServiceStartArguments.java
SEE:
1.
HandlerThread thread = new HandlerThread("ServiceStartArguments",
Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
mServiceLooper = thread.getLooper();
mServiceHandler = new ServiceHandler(mServiceLooper);
SO:
1.
创建一个线程,开始,取得Looper(),通过Looper创建Handler,并实现其hendlerMessage的方法
SEE:
1.
// We show this for as long as our service is processing a command.
notification.flags |= Notification.FLAG_ONGOING_EVENT;
SO:
当service在处理command的时候notification存在。
SEE:正常路线
1.
startService(new Intent(Controller.this,
ServiceStartArguments.class)
.putExtra("name", "One"));
2.
public int onStartCommand(Intent intent, int flags, int startId) {
Message msg = mServiceHandler.obtainMessage();
msg.arg1 = startId;
msg.arg2 = flags;
msg.obj = intent.getExtras();
mServiceHandler.sendMessage(msg);
3.
public void handleMessage(Message msg) {
Bundle arguments = (Bundle)msg.obj;
String txt = arguments.getString("name");
Log.i("ServiceStartArguments", "Message: " + msg + ", "
+ arguments.getString("name"));
if ((msg.arg2&Service.START_FLAG_REDELIVERY) == 0) {
txt = "New cmd #" + msg.arg1 + ": " + txt;
} else {
txt = "Re-delivered #" + msg.arg1 + ": " + txt;
}
showNotification(txt);
4.
long endTime = System.currentTimeMillis() + 5*1000;
while (System.currentTimeMillis() < endTime) {
synchronized (this) {
try {
wait(endTime - System.currentTimeMillis());
} catch (Exception e) {
}
}
}
hideNotification();
Log.i("ServiceStartArguments", "Done with #" + msg.arg1);
stopSelf(msg.arg1);
}
5.
public void onDestroy() {
mServiceLooper.quit();
hideNotification();
// Tell the user we stopped.
Toast.makeText(ServiceStartArguments.this, R.string.service_destroyed,
Toast.LENGTH_SHORT).show();
}
SO:
1.
启动SERVICE
2.
将启动时的状态,发送给HANDLER处理
3.
当flag为Service.START_FLAG_REDELIVERY的时候做不同的处理
4.
等待5秒,关掉NOTIFICATION.
5.
接下来继续处理其他的MESSAGE,所以每一个NOTIFICATION将持续五秒。直到所有的MESSAGE处理完了,调用HANDLER的onDestory方法,这是显示 service destory 的 toast
SEE:不正常路线 FAIL
1.
private OnClickListener mStartFailListener = new OnClickListener() {
public void onClick(View v) {
startService(new Intent(Controller.this,
ServiceStartArguments.class)
.putExtra("name", "Failure")
.putExtra("fail", true));
}
};
2.
// For the start fail button, we will simulate the process dying
// for some reason in onStartCommand().
if (intent.getBooleanExtra("fail", false)) {
// Don't do this if we are in a retry... the system will
// eventually give up if we keep crashing.
if ((flags&START_FLAG_RETRY) == 0) {
// Since the process hasn't finished handling the command,
// it will be restarted with the command again, regardless of
// whether we return START_REDELIVER_INTENT.
Process.killProcess(Process.myPid());
}
}
3.
点击 start failed delivery 并等待
SO:
1.
启动service
2.
第一次启动服务的时候,flag肯定不是START_FLAG_RETRY,所以killProcess。
3.
killProcess后 service自动重启。这时的FLAG为START_FLAG_RETRY 所以正常显示NOTIFICATION
SEE:不正常路线 redeliver
1.
startService(new Intent(Controller.this,
ServiceStartArguments.class)
.putExtra("name", "Three")
.putExtra("redeliver", true));
2.
return intent.getBooleanExtra("redeliver", false)
? START_REDELIVER_INTENT : START_NOT_STICKY;
3.
点击 start three 并观察
4.
再次点击 start three 在 service destoryed之前点击 kill Process,并观察
SO:
1.
设置相关配置,开始service
2.
返回 START_REDELIVER_INTENT 表示需要当service 意外终止时重新发送 intent
3.
没有意外终止,显示new command
4.
意外终止,显示re_delivered,表明,该SERVICE重启,并重新接受INTENT
TextToSpeechActivity.java
SEE:
1.
mTts = new TextToSpeech(this,this // TextToSpeech.OnInitListener
);
2.
// Implements TextToSpeech.OnInitListener.
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = mTts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA ||
result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e(TAG, "Language is not available.");
} else {
mAgainButton.setEnabled(true);
}
} else {
Log.e(TAG, "Could not initialize TextToSpeech.");
}
}
3.
mTts.speak(hello,
TextToSpeech.QUEUE_FLUSH, // Drop all pending entries in the playback queue.
null);
SO:
1.创建实例
2.监听初始化
3.说话。。
VoiceRecognition.java
无法测试。。
====================================APP完~ 好像解密游戏呀
相关推荐
《Android 2.2 ApiDemos深度解析》 在Android开发领域,ApiDemos是一个非常重要的参考资料,它是由Google官方提供的一个示例程序,包含了Android SDK中的各种API功能的演示。这个项目,针对的是Android 2.2(API...
**Android 6.0 API Demos详解** Android 6.0 API Demos 是一个官方提供的示例代码集合,它展示了Android 6.0 (Marshmallow) SDK中的各种API功能和用法。这些示例旨在帮助开发者更好地理解和学习如何在实际应用中...
API Demos 是 Google 为了 Android 开发者所提供的一个 Android API 合集,其中包含了很多的 API 范例,同时遵循了良好的代码规范,是一个值得开发者研究和学习的典型。android的ApiDemos,需要解压缩后使用。
Android官网ApiDemos源码 供大家学习参考之用
《深入探索Android API Demos:最新实践与技术解析》 Android API Demos是Google官方提供的一款用于展示Android SDK中各种API功能和用法的应用程序,它涵盖了从基础控件到高级特性的全方位示例,是开发者学习...
《Android 1.6 API Demos深度解析》 在Android开发的世界中,API Demos是一个不可或缺的学习资源,它为开发者提供了丰富的示例代码,帮助理解并掌握Android API的各种功能。本篇文章将深入探讨"android1.6 apiDemos...
《Android ApiDemos apk:深入理解Android应用开发的实践指南》 Android ApiDemos apk是Android开发者们熟悉的一个示例程序,它包含了Android SDK中的各种API功能演示,为开发者提供了丰富的学习资源。这个应用程序...
从官方预览包里提取的Android6.0 ApiDemos.apk,方便安装在真机上查看实例的实际效果。
Android 5.1的ApiDemos安装包
《Android 4.3 ApiDemos深度解析》 在Android操作系统的发展历程中,每个版本的更新都会带来新的特性和API,以提升用户体验和开发者的工作效率。Android 4.3(API级别18)是Android系统的一个重要里程碑,它引入了...
《深入解析Android 4.1 ApiDemos》 在Android开发领域,ApiDemos是一个非常重要的参考资料,它是由Google官方提供的示例代码集合,用于演示Android SDK中的各种API功能。对于开发者来说,尤其是对Android 4.1...
最新版ApiDemos Android SDK 中带有很多例子,其中ApiDemo 详细介绍了Android 平台主要API,分成了 · App · Content · Graphics · Media · OS · Text · Views 几个大类,每个大类又分为几个小类,...
《Android 3.0 ApiDemos详解》 在Android开发领域,`ApiDemos`是一个非常重要的学习资源,它是Google官方提供的一款示例程序,包含了Android SDK中的各种API功能演示。这个项目主要用于帮助开发者理解并熟悉Android...
《Android ApiDemos详解——深度探索Android开发应用实例》 Android ApiDemos是Android开发者学习和理解Android API的重要资源,它包含了丰富的示例代码,涵盖了Android SDK中的各种API功能。这个程序是专为Android...
**Android ApiDemos详解** `Android ApiDemos` 是Android系统提供的一款官方示例程序,它集合了Android SDK中的各种API用法,是开发者学习和理解Android开发的关键资源。这个项目旨在通过实例代码来演示Android API...
《Android API Demos详解》 Android API Demos是一款由谷歌官方提供的开源项目,它包含了大量Android SDK中的API示例代码,旨在帮助开发者更好地理解和学习如何在实际应用中使用Android的各种功能和API。该项目覆盖...
**Android ApiDemos详解** ApiDemos是Android官方提供的一款示例应用,它包含了Android SDK中的各种API功能演示,帮助开发者了解和学习Android系统提供的各种API接口和功能。这个"Android ApiDemos不报错版本"是...
《Android API 19 ApiDemos详解》 在Android开发领域,API Demos是一个非常重要的学习资源,它包含了Android SDK中的各种API示例代码,帮助开发者深入理解和掌握Android平台的功能特性。本文将针对API Level 19...
《Android ApiDemos不报错版本:探索与学习》 Android ApiDemos是Android平台上的一个官方示例项目,它为开发者提供了丰富的API演示,涵盖了Android系统中的各种控件和功能,是学习和理解Android开发的宝贵资源。这...