Android 一個應用去獲取另一個應用assets下面的資源通過框架代碼橋梁------項目實戰成功案例。
最終效果
HelloWord工程應用代碼:
- package com.pateo;
-
- import android.app.Activity;
- import android.os.Bundle;
- import android.widget.TextView;
- import com.pateo.R;
- import android.content.pm.PackageManager;
-
- public class HelloWordActivity extends Activity {
-
- TextView tv ;
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- tv = (TextView)findViewById(R.id.tv);
-
- PackageManager pm = getPackageManager();
- try{
- tv.setText("result : " + pm.getAppVoiceEntryInfo("packageName", "xmlName", "bnfName").speechContent);
- }catch( android.content.pm.PackageManager.NameNotFoundException e){
- tv.setText("" + e);
- }
-
- }
- }
上面getAppVoiceEntryInfo不是PackageManager自帶的方法是我自己添加的方法