我需要编译具有系统权限的应用程序才能使用目标应用程序com.android.settings.现在,当我尝试运行我的apk时,我收到错误消息
测试运行失败:权限拒绝:从pid = 354开始检测ComponentInfo {com.jayway.test/android.test.InstrumentationTestRunner},因为包com.jayway.test没有与目标com匹配的签名,所以不允许使用uid = 354. android.settings
如何使用系统权限编译我的应用程序?
我正在尝试使用一些参数进行Instrumentation测试.我注意到我可以通过System.getProperty()函数读取系统属性.所以我使用setprop命令设置系统属性.例如:adb shell setprop AP 123.在我的测试代码中,我尝试用以下内容读取此AP属性:
tmp = System.getProperty("AP");
Log.d("MyTest","AP Value = " + tmp);
Run Code Online (Sandbox Code Playgroud)
然后我使用logcat查看此调试消息,但我得到此属性的空值.关于什么可能出错的任何想法?请注意,我仍然可以使用adb shell getprop AP命令读取系统属性.
我正在使用发送带附件的电子邮件的意图,它工作正常,我想获得此电子邮件意图结果,我已经使用过startActivityforResult(),但我无法获得电子邮件意图的结果,我们如何使用startActivityforResult()电子邮件意图?
谢谢大家
我正在打开一个Activity使用这个:
startActivity(new Intent(Parent.this, Child.class));
Run Code Online (Sandbox Code Playgroud)
在孩子身上,我在onCreate函数上有这个代码(当然if包含的不仅仅是true):
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (true) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setPositiveButton("OK", null);
builder.setTitle("Error");
builder.setMessage("Connection error, please try later.")
.show();
finishActivity(0);
return;
}
}
Run Code Online (Sandbox Code Playgroud)
为什么活动没有结束?我收到警报框,但是我必须点击"后退"按钮才能返回.
我有一个WebView,以html格式显示Google Checkout付款按钮.
当我在模拟器上运行它时,它有工作,有付款按钮,我可以按它并转到谷歌结帐网页.
但是,当我在运行Android 2.2的实际设备上运行它时,它只显示带有问号的小蓝框.
这是什么意思?
String header =
"<html>" +
"<head>" +
"<script language=\"javascript\">"+
"function pass() {"+
"return checkboxState.checkboxPass();"+
"}"+
"</script>" +
"</head>" +
"<body>";
String formData =
"<center>"+
"<form onSubmit=\"return pass();\" action=\"https://"+host+"api/checkout/v2/checkoutForm/Merchant/"+merchantId+"\" id=\"BB_BuyButtonForm\" method=\"post\" name=\"BB_BuyButtonForm\" target=\"_blank\">"+
"<input name=\"item_name_1\" type=\"hidden\" value=\""+item_name_1+"\"/>"+
"<input name=\"item_description_1\" type=\"hidden\" value=\""+item_name_1+"\"/>"+
"<input name=\"item_quantity_1\" type=\"hidden\" value=\"1\"/>"+
"<input name=\"item_price_1\" type=\"hidden\" value=\""+item_price_1+"\"/>"+
"<input name=\"item_currency_1\" type=\"hidden\" value=\""+item_currency_1+"\"/>"+
"<input name=\"_charset_\" type=\"hidden\" value=\"utf-8\"/>"+
"<input type=\"hidden\" name=\"shopping-cart.items.item-1.merchant-private-item-data\" value=\""+private_item_data+"\">"+
"<input alt=\"Pay With Google Checkout\" src=\"https://"+host+"buttons/buy.gif?merchant_id="+merchantId+"&w=121&h=44&style=trans&variant=text&loc=en_US\" type=\"image\"/>"+
"</form>"+
"</center>";
String footer = "</body></html>";
if(Logging.DEBUG) …Run Code Online (Sandbox Code Playgroud) 我想在退出应用程序时显示一个简单的toast.问题是,没有显示吐司.我认为这是因为活动完成或因为System.exit(0),但我不知道如何解决它.有人有小费吗?谢谢!!
在我的活动中,我有以下代码:
Toast.makeText(this,"Exit application.",Toast.LENGTH_SHORT).show();
exitApp();
public void exitApp (){
App.getInstance().exit();
finish();
}
Run Code Online (Sandbox Code Playgroud)
App中的mehod退出:
public void exit() {
System.exit(0);
}
Run Code Online (Sandbox Code Playgroud) 当我将我的应用程序安装到设备或模拟器上时,它会在应用程序菜单中多次出现,在我的情况下,我会看到4个图标显示我的应用程序名称.
似乎每个图标代表一个活动,并且由于我的应用程序包含3个选项卡(带有活动),我的菜单上的前3个图标转到特定活动,第4个图标将我带到应用程序本身
这是我的表现
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jameselsey"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:name="com.jameselsey.domain.GlobalState"
android:theme="@android:style/Theme.NoTitleBar">
<activity android:name=".DefaultActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MyContactsActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MyMapsActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".OptionsActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> …Run Code Online (Sandbox Code Playgroud) 我在android源代码中找到了示例插件.假设我可以使用该示例编写插件,如何让我的模拟器运行我编写的插件?我需要重新编译源代码吗?如果是,那怎么可能呢?
谢谢:)
我想知道如何以编程方式集中GUI小部件.请帮助我.我正在使用LinearLayout.
许多问候.
final Intent i = new Intent(android.content.Intent.ACTION_SEND);
i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ txt.getText().toString()});
i.putExtra(Intent.EXTRA_SUBJECT, "Merry Christmas");
i.setType("text/html");
Spanned html =Html.fromHtml("<html><body>h<b>ell</b>o<img src='http://www.pp.rhul.ac.uk/twiki/pub/TWiki/GnuPlotPlugin/RosenbrockFunctionSample.png'>world</body></html>",
new ImageGetter() {
InputStream s;
public Drawable getDrawable(String url) {
try {
s = (InputStream) (new URL(url)).getContent();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Drawable d = Drawable.createFromStream(s, null);
LogUtil.debug(this, "Got image: " + d.getClass() + ", " + d.getIntrinsicWidth() + "x" + d.getIntrinsicHeight());
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
return d;
}},null);
i.putExtra(Intent.EXTRA_TEXT, html);
startActivity(Intent.createChooser(i, "Send email"));*
Run Code Online (Sandbox Code Playgroud) android ×10
adb ×1
alignment ×1
launcher ×1
permissions ×1
plugins ×1
system.exit ×1
toast ×1
webview ×1