我正在尝试使用Android Runtime将现有的Android应用程序移植到BlackBerry 10.首先,我需要提一下,我已成功将一个简单的Android应用程序移植到BlackBerry 10而没有任何错误.我在这个过程中使用了Eclipse的"插件重新打包工具".
在此应用程序中,它会因为包含项目ProjectName而导致错误,因为它有验证错误.生成错误后,它会在代码中显示错误.代码的错误行如下.
intent.addCategory(Intent.CATEGORY_HOME);
Run Code Online (Sandbox Code Playgroud)
携带上述行的完整代码块如下.
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
当我评论该代码块并尝试为AppWorld登录时,它工作正常.
上面的代码片段如何影响移植和生成错误?
我的网页上有以下代码.
<div id="" class="user_acc_setails">
<ul id="accDtlUL">
<li>First Name: <span id="f_name">Anuja</span></li>
Run Code Online (Sandbox Code Playgroud)
到页面加载时,未设置Sapn的值.设置值需要很短的时间.我想等待并在我的Python文件中获取该值.
我目前正在使用以下代码,
element = context.browser.find_element_by_id('f_name')
assert element.text == 'Anuja'
Run Code Online (Sandbox Code Playgroud)
但它给了我一个AssetionError.我怎么解决这个问题?
谢谢
我正在尝试从成功的 API 请求中提取一个值,该请求正在使用 Postman 发送 XML 响应。以下是我尝试从响应中获取所需值的方法。
var jsonObject = xml2Json(responseBody);
console.log(jsonObject);
postman.setGlobalVariable("Active_SAML", jsonObject.bankidCollectResponse.SAMLReferens);
console.log(pm.globals.get("Active_SAML"));
Run Code Online (Sandbox Code Playgroud)
在“测试”选项卡中编写的脚本和控制台注销如下。
但是当我执行程序时,出现以下错误。
评估测试脚本时出错:TypeError: Cannot read property 'SAMLReferens' of undefined
我不确定我在哪里做错了。有人可以指出我吗?
这是我认为准确的buttonAdapter类:
package com.example.test;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
public class ButtonAdapter extends BaseAdapter {
private Context mContext;
public String [] fName = { "File 1", "File 2", "Roflcopters"};
// Gets the context so it can be used later
public ButtonAdapter(Context c) { mContext = c; }
// Total number of things contained within the adapter
public int getCount () { return 8; }
// Require for structure, not really used in …
Run Code Online (Sandbox Code Playgroud) 我想使用Appium对HelloWorld Android应用程序进行简单的单元测试.我的Android应用程序有一个Activity,在屏幕上加载后,它会在TextView上显示"Hello World".我想要的是使用Python编写一个单元测试用例,它按照我的预期工作并使用Appium进行测试.
我无法理解的主要是我的Android项目,Appium和Python脚本之间的联系.
我想我已经在我的Ubuntu-12.04中正确配置了Appium.当我在终端中给出以下命令时
anuja@anuja-MulTplx:~$ appium &
Run Code Online (Sandbox Code Playgroud)
它给出了以下回应
anuja @ anuja-MulTplx:〜$ info:Appium REST http接口监听器在0.0.0.0:4723上启动
我用Selenium WebDriver为Web单元测试编写了简单的Python脚本.但我不知道如何使用Appium编写Python脚本来测试我的Android应用程序.需要一个示例或良好的文档.
谢谢
我在@ Dan Cuellar回答之后添加了这部分内容.
在我使用一个终端启动服务器后,我从另一个包含python绑定的终端运行我的python脚本.
在Appium服务器运行终端上,它提供了以下输出
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"sessionId":null,"desiredCapabilities":{"app-package":"my.app.package","app":"/home/anuja/MobileDev/apks_and_keys/Trickbook.apk","browserName":"","version":"4.0.4","device":"Android","app-activity":"TrickbookSplasher"}}
info: Using local app from desiredCaps: /home/anuja/MobileDev/apks_and_keys/Trickbook.apk
info: Creating new appium session 4788d549-d39a-4730-9bdb-382418c2b2c9
info: Starting android appium
debug: Using fast reset? true
info: Preparing device for session
info: Checking whether app is actually present
info: Checking whether adb is present
info: [ADB] Using …
Run Code Online (Sandbox Code Playgroud) 我已经构建了一个Android应用程序,它捕获图像并保存在/ mnt/sdcard/Pictures/MyFolder中.实际上应用程序运行正常,并且图像存储在给定路径中.问题是在重新启动设备之前我无法看到图像.我可以处理编码中的情况吗?
提前致谢.
我想创建一个只在应用程序启动后显示一次的屏幕.之后,它只会显示主屏幕.我实现这个的方法只是检查首选项并根据标志设置当前布局.有没有以这种方式实施它的缺点?有没有更好的办法?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Here is the main layout
setContentView(R.layout.main);
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
// second argument is the default to use if the preference can't be found
Boolean welcomeScreenShown = mPrefs.getBoolean(welcomeScreenShownPref, false);
if (!welcomeScreenShown) {
//Here I set the one-time layout
setContentView(R.layout.popup_message);
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(welcomeScreenShownPref, true);
editor.commit(); // Very important to save the preference
}
}
Run Code Online (Sandbox Code Playgroud) 如何降低RotateAnimation实例的旋转速度.我正在使用以下代码片段来制作动画.
rotateAnimation = new RotateAnimation(currentRotation, currentRotation + (360 * 5), Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
currentRotation = (currentRotation + (360 * 5));
rotateAnimation.setDuration(10000);
rotateAnimation.setInterpolator(new LinearInterpolator());
rotateAnimation.setRepeatCount(Animation.INFINITE);
rotateAnimation.setRepeatMode(Animation.INFINITE);
rotateAnimation.setFillEnabled(true);
rotateAnimation.setFillAfter(true);
rotateAnimation.setAnimationListener(animationInListener);
recordRingImageView.startAnimation(rotateAnimation);
Run Code Online (Sandbox Code Playgroud) android linear-interpolation android-animation rotateanimation
我需要创建一个如下所示的UI.
当我编写代码并运行应用程序时,它会加载第一个选项卡,即"类别".我需要的是加载第二个选项卡,当我运行应用程序而不更改Tab顺序时,它是"Home".
以下是我的代码.
以下事项我需要你的帮助.我想读取JSON文件的父标签.以下是我的JSON文件内容;
{
"ebook":
[
{"id":"1","name":"book1"},
{"id":"2","name":"book2"}
],
"ebrochure":
[
{"id":"1","name":"brochure1"},
{"id":"2","name":"brochure2"}
],
"emenu":
[
{"id":"1","name":"menu1"},
{"id":"2","name":"menu2"}
]
}
Run Code Online (Sandbox Code Playgroud)
我只需要找出JSON中有多少个父标签以及它们是什么.根据我给出的JSON文件,答案应该是3(有3个父JSON标签)和" ebooks,ebrochure,emenu "(父标签的名称).是否有任何JAVA课程我可以完成我的工作?
我知道如何阅读完整的JSON文件.首先,我们将JSON传递给a JSONObject
,然后通过JSONArray
using getJSONArray()
方法将子句传递给a .
但是getJSONArray()
方法需要父标记的名称.根据我的例子,它可以是电子书,ebrochure或emenu.假设有一种情况我们看不到JSON的内容只访问URL.在这种情况下,我需要找出有多少父母标签,以及它们的名称.
那是我的问题.在此先感谢帮助我:-)
我有一个对话框显示,我希望在按下后退按钮时要求用户确认他要在取消生效前取消对话框.这是我的代码:
dialog.setOnCancelListener(new OnCancelListener(){
@Override
public void onCancel(DialogInterface arg0) {
AlertDialog.Builder builder = new AlertDialog.Builder(dialog.getContext());
builder.setMessage( "Are you sure you want to cancel?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface diag, int id) {
diag.dismiss();
dialog.dismiss();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface diag, int id) {
diag.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
dialog.show();
Run Code Online (Sandbox Code Playgroud)
问题是,当按下后退按钮时,我的当前对话框被取消,然后显示我的"确认消息".在用户确认对话框之前,如何确保不取消对话框?
我正在使用一个带有android.support.v4.view.ViewPager布局的Activity,我用它来操作Tab导航.我有不同的片段用于不同的标签.在我的第三个标签上,我正在从我的YouTube帐户中加载一些YouTube缩略图.
当我加载应用程序时(当我停留在第一个选项卡上时)并按返回退出应用程序,它存在没有任何问题.但是,当我导航到第二个选项卡并尝试按"返回"按钮时,应用程序存在,并显示如下错误.
E/ActivityThread(7187): Activity package.name.ActivityName has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@41e5d180 that was originally bound here
E/ActivityThread(7187): android.app.ServiceConnectionLeaked: Activity package.name.ActivityName has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@41e5d180 that was originally bound here
Run Code Online (Sandbox Code Playgroud)
我已将YouTube Data API v3添加到我的项目中.
我该如何解决这个问题?退出第二个选项卡而不是第一个选项卡时出现错误的原因是什么?
这不是一个重复的问题,这.
android memory-leaks serviceconnection android-fragments android-youtube-api
android ×10
python ×2
unit-testing ×2
appium ×1
arrays ×1
assertions ×1
eclipse ×1
fragment ×1
gridview ×1
json ×1
memory-leaks ×1
onitemclick ×1
postman ×1
selenium ×1
testcase ×1
ubuntu-12.04 ×1
version ×1
xml ×1