小编gro*_*roo的帖子

如何在Android中进行后台工作时使用AsyncTask显示ProgressDialog?

可能重复:
从AsyncTask更新Activity中的进度对话框

我正在开发我的第一个Android应用程序,我需要显示ProgressDialog,而后台任务,在这种情况下只是服务器上的http调用.我对此进行了一些研究,并且已经检查了与此主题相关的其他线程.

http://developer.android.com/reference/android/os/AsyncTask.html

Android显示ProgressDialog,直到活动UI完成加载

Android SplashScreen

http://android-developers.blogspot.com/2009/05/painless-threading.html

其中包括.

比起我要编写一些代码:

1)在My Activity中,我声明一个变量为ProgressDialog类型

public class LoginActivity extends Activity {

    public static final String TAG = "LoginActivity";

    protected ProgressDialog progressDialog; 
...
Run Code Online (Sandbox Code Playgroud)

2)我还编写了一个内部类来根据需要扩展AsyncTask,这里我在doInBackGround中调用静态方法,它实际上向服务器发出POST http请求,在服务器端我已经阻止服务器响应20s验证进度对话框.

class EfetuaLogin extends AsyncTask<Object, Void, String> {

        private final static String TAG = "LoginActivity.EfetuaLogin";

        @Override
        protected void onPreExecute()
        {
            Log.d(TAG, "Executando onPreExecute de EfetuaLogin");
        }


        @SuppressWarnings("unchecked")
        @Override
        protected String doInBackground(Object... parametros) {
            Log.d(TAG, "Executando doInBackground de EfetuaLogin");
            Object[] params = parametros;
            HttpClient httpClient = (HttpClient) params[0];
            List<NameValuePair> listaParametros = …
Run Code Online (Sandbox Code Playgroud)

android progressdialog android-asynctask

21
推荐指数
2
解决办法
7万
查看次数

Ionic Cordova FileUpload错误:不允许加载本地资源

我是Ionic的新手,我正在尝试上传从Android文件系统中存储的相机拍摄的图像:

var ft = new FileTransfer();
console.log('Uploading: ' + fileURL);
ft.upload(fileURL,
  encodeURI("http://192.168.192.62:3000/api/meals/picture"),
  pictureUploaded,
  function(error) {
    console.err(error);
    $ionicLoading.show({template: 'Ooops error uploading picture...'});
    setTimeout(function(){$ionicLoading.hide();}, 3000);
  },
  options);

var pictureUploaded = function() {
  console.log('uploaded!');
  $ionicLoading.hide();
};
Run Code Online (Sandbox Code Playgroud)

fileUrl指向一个现有的图像:file:///data/data/com.ionicframework.nutrilifemobile664547/files/Q2AtO1462636767466.jpg

在chrome:// inspect /#devices console中我收到以下错误,看起来因为错误,FileOptions也没有正确发送,这是错误(不允许加载本地资源):

在此输入图像描述

Cordova版本:6.1.1离子版本:1.7.14

有任何想法吗?我一直坚持这个错误.

mobile android cordova ionic-framework

17
推荐指数
1
解决办法
6550
查看次数

如何将JSon作为BODY发送到Android应用程序的服务器POST请求中?

我正在开发我的第一个Android应用程序.我想要做的是对REST服务的POST请求我希望此请求的BODY是JSON字符串.

我正在使用谷歌的GSON生成发送到服务器的JSON.这是执行POST请求的代码:

HttpPost requisicao = new HttpPost();
requisicao.setURI(new URI(uri));
requisicao.setHeader("User-Agent", sUserAgent);
requisicao.setHeader("Content-type", "application/json");
HttpResponse resposta = null;
//I can see the json correctly print on log with the following entry.
Log.d(TAG, "JSon String to send as body in this request ==>> " + jsonString);
//than I try to send JSon using setEntityMethod
StringEntity sEntity = new StringEntity(jsonString, "UTF-8");
requisicao.setEntity(sEntity);

resposta = httpClient.execute(requisicao);
resultado = HttpProxy.leRespostaServidor(resposta);
Run Code Online (Sandbox Code Playgroud)

响应代码是400 BAD REQUEST,从服务器日志中我可以读取信息.它说身体没有正确发送:

13:48:22,524 ERROR [SynchronousDispatcher] Failed executing POST /peso/cadastrar/maia.marcos@gmail.com
org.jboss.resteasy.spi.BadRequestException: Could not find message …
Run Code Online (Sandbox Code Playgroud)

rest post android json seam

13
推荐指数
1
解决办法
2万
查看次数

如何使用xml布局引用在自定义对话框中创建的Button?

我有一个活动,用户可以在标签附近的按钮中更新特定信息.这个按钮比触发一个Dialog,我有一些字段来获取用户输入和一个按钮来完成编辑.

我的问题是我无法获得对话框特定的xml布局中的按钮声明的引用.按钮引用返回null.按照一些代码片段进行说明.

触发事件以构建对话框的按钮在活动中声明为实例变量,如下所示:

private Button bConfigurarCarro;
Run Code Online (Sandbox Code Playgroud)

比onCreate方法:

bConfigurarCarro = (Button)findViewById(R.id.bConfigurarCarro);
 bConfigurarCarro.setOnClickListener(configuraCarroListener);
Run Code Online (Sandbox Code Playgroud)

这会正确触发事件以创建对话框:

protected OnClickListener configuraCarroListener = new OnClickListener(){
public void onClick(View v) {
showDialog(CARRO_DIALOG_ID);
Log.d(TAG, "Executando evento do botão de configuração de carro no abastecimento.");
            }
        };
Run Code Online (Sandbox Code Playgroud)

而不是创建对话框覆盖onCreateDialog方法,如下所示:

@Override
protected Dialog onCreateDialog(int id) {
  switch (id) {
    case TIME_DIALOG_ID:
        return new TimePickerDialog(this, mTimeSetListener, hora, minuto, false);
    case DATE_DIALOG_ID:
        return new DatePickerDialog(this, mDateSetListener, ano, mes, dia);
    case CARRO_DIALOG_ID:
        Log.d(TAG, "Criando dialog de cadastro de carro.");
        dialogCarro = new Dialog(this);
        dialogCarro.setContentView(R.layout.novo_carro_dialog);
        bSalvarCarro …
Run Code Online (Sandbox Code Playgroud)

android dialog reference button

13
推荐指数
1
解决办法
3万
查看次数

如何使用weblogic 10.3.x在web.xml中动态传递参数?

我正在尝试在启动weblogic服务器时使用-D表示法将web.xml中配置的变量的JVM参数作为context-parameter传递.我已经使用Tomcat 7尝试了相同的配置,它按预期工作,但它不能在weblogic服务器10.3.3中工作.有线索吗?

web.xml中

<?xml version="1.0" encoding="UTF-8" ?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
    <display-name>testeParWebXml</display-name>
    <context-param>
        <description>Habilita ou desabilita a configuração de debug do Facelets! Página de debug do Seam.</description>
        <param-name>facelets.DEVELOPMENT</param-name>
        <param-value>${habilitar.debug}</param-value>
    </context-param>
<welcome-file-list>
Run Code Online (Sandbox Code Playgroud)

然后在启动jvm时我使用以下参数传递:

-Dhabilitar.debug=true
Run Code Online (Sandbox Code Playgroud)

我构建了一个Servlet来测试:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter pw = response.getWriter();
        String valorParametro = getServletContext().getInitParameter("facelets.DEVELOPMENT");
        pw.write("Param value from web.xml ==>> " + valorParametro);
}
Run Code Online (Sandbox Code Playgroud)

正如我提到的使用Tomcat,如果我在-Dhabilitar.debug标志中将值更改为false或true,它会正确地在servlet中打印该值.

Param value from web.xml ==>>  true
Run Code Online (Sandbox Code Playgroud)

在weblogic中,我得到的输出如下:

Param value from web.xml ==>>  ${habilitar.debug}
Run Code Online (Sandbox Code Playgroud)

注意,weblogic不会解析web.xml中变量集的值. …

parameters configuration web.xml weblogic

6
推荐指数
1
解决办法
3万
查看次数

使用ansible-playbook安装docker-compose时出错

我有一个非常简单的Ansible playbook,为docker-compose和docker安装了所有依赖项,但是在安装docker-compose时遇到错误,这是我的playbook上安装docker-compose在CentOS7环境中的任务.

    #ensure docker-compose and chmod +x /usr/local/bin/docker-compose
  - name: Ensure docker-compose is installed and available
    command: curl -L https://github.com/docker/compose/releases/download/1.7.0-rc1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
  - name: Ensure permissions docker-compose
    command: chmod +x /usr/local/bin/docker-compose
Run Code Online (Sandbox Code Playgroud)

出现以下错误:

TASK: [Ensure docker-compose is installed and available] ********************** 
failed: [nutrilife-aws] => {"changed": true, "cmd": ["curl", "-L", "https://github.com/docker/compose/releases/download/1.7.0-rc1/docker-compose-`uname", "-s`-`uname", "-m`", ">", "/usr/local/bin/docker-compose"], "delta": "0:00:00.004592", "end": "2016-03-26 14:19:41.852780", "rc": 2, "start": "2016-03-26 14:19:41.848188", "warnings": ["Consider using get_url module rather than running curl"]}
stderr: curl: option -s`-`uname: is unknown …
Run Code Online (Sandbox Code Playgroud)

ansible docker ansible-playbook docker-compose

6
推荐指数
2
解决办法
2727
查看次数

使用Spring数据的postgres中的时间戳错误:列$ COLUMN_NAME的类型为timestamp,没有时区,但表达式的类型为bytea

使用以下内容:

Oracle JDK 1.8.0._171

Spring Boot 1.5.9-发布

PostgreSQL 9.6

Postgres驱动程序:42.2.4

从以下定义获取错误:

表格栏: sql meal_time TIMESTAMP DEFAULT now() NOT NULL

实体属性定义: java @Column(name = "meal_time", nullable=false) private Instant mealTime = Instant.now();

每当我尝试刷新或查询实体时,都会引发错误:

Caused by: org.postgresql.util.PSQLException: ERROR: column "meal_time" is of type timestamp without time zone but expression is of type bytea
  Hint: You will need to rewrite or cast the expression.
Run Code Online (Sandbox Code Playgroud)

我可以为这个领域编写一个转换器,但是应该有一种标准的方法,感觉就像是我在寻找一些实例的过程中缺少了一些东西,这些实例我发现非常接近的实现确实有效。

postgresql spring hibernate jpa spring-boot

5
推荐指数
1
解决办法
2131
查看次数

如何使用Samsumg Galaxy 5设备开发Android应用程序?

我正在开发我的第一个Android应用程序.我已经在2010年4月发布的Ubuntu 10.04 LTS - Lucid Lynx上的模拟器(Eclipse + Android开发工具)上运行了一个应用程序.我已经在此链接上尝试了Android开发者门户网站提供步骤,但每当我尝试使用./adb设备列出我已连接的设备我得到以下内容:

mmaia@mmaia-desktop:~/tools/android-sdk-linux_86/tools$ ./adb devices
List of devices attached 
????????????    no permissions
Run Code Online (Sandbox Code Playgroud)

我已经检查过,当我运行虚拟仿真器时,同样的命令返回:

List of devices attached 
????????????    no permissions
emulator-5554   device
Run Code Online (Sandbox Code Playgroud)

另外当我要求eclipse运行模拟器时它会找到设备(galaxy 5),看下面的图片,但是找不到串口,可能是因为有些许可,我只能选择虚拟模拟器.

替代文字

如何在Ubuntu 10.04下为Android开发时配置将Galaxy 5用作设备的权限?

[]中

linux ubuntu android device

3
推荐指数
1
解决办法
3474
查看次数

Node.js Readline,获取当前行号

我有以下实现,除了此行以外,其他所有方法均有效:

lineNumber: line.lineNumber
Run Code Online (Sandbox Code Playgroud)

该行返回未定义,我在下面添加了完整的代码片段,我的问题是:Readline是否提供一种以某种方式获取行号的标准方法?还是我必须实现计数器来跟踪行号,这很简单,但是我不希望有标准的方法吗?

/**
* Search for occurrences of the specified pattern in the received list of files.
* @param filesToSearch - the list of files to search for the pattern
* @returns {Promise} - resolves with the information about the encountered matches for the pattern specified.
*/
const findPattern = (filesToSearch) => {
console.log(filesToSearch);
return new Promise((resolve, reject) => {
 var results = [ ];
 // iterate over the files
 for(let theFile of filesToSearch){
  let dataStream = fs.createReadStream(theFile); …
Run Code Online (Sandbox Code Playgroud)

javascript node.js

3
推荐指数
2
解决办法
2290
查看次数

有没有办法从2路ssl连接中的java代码恢复客户端证书的通用名称?

我们有一个weblogic服务器,配置为在与客户端建立与Web服务解决方案的ssl连接时需要客户端证书.ssl握手完美地工作,因为我们已经配置了所需的全部内容.

现在,在连接之后我们收到一个soap请求,其中客户端ID是此请求soap的字段之一.我们需要做的是检查此id与用于在我们的服务器内连接的客户端证书的通用名称,以保证交易.这对我们来说非常重要,因为这是银行交易,涉及很多钱,我们需要避免欺诈.

那么:有没有办法恢复用于使用weblogic 10.3.3服务器在服务器上运行的java代码建立双向ssl连接的客户端证书的通用名称?

[]中

java ssl soap weblogic

1
推荐指数
1
解决办法
2611
查看次数

在模型的远程方法中使用查找时,回送顺序过滤器错误:

我在使用远程方法的查找中使用简单的排序过滤器时遇到了麻烦:

    /**
 * This remote method exposes the meals history from the current logged in user
 */
Meal.listMeals = function(req, res, cb) {
  Meal.find({
    where: {patientId: req.accessToken.userId},
    order: {mealDate: 'DESC'}
  }, cb);
};
Meal.remoteMethod('listMeals', {
  returns: {arg: 'meals', type: 'array'},
  http: {path:'/list-meals', verb: 'get'},
  accepts: [
    {arg: 'req', type: 'object', http: {source: 'req'}},
    {arg: 'res', type: 'object', http: {source: 'res'}}
  ]
});
Run Code Online (Sandbox Code Playgroud)

在上方,您可以看到我的remote / find实现,它在没有订单过滤器的情况下也可以正常运行。

订单{“ mealDate”:“ DESC”}无效

mealDate是我模型上的Date类型。

"properties": {
"mealDate": {
  "type": "date",
  "required": true,
  "default": "Date.now"
}, …
Run Code Online (Sandbox Code Playgroud)

sorting loopback node.js loopbackjs

1
推荐指数
1
解决办法
1461
查看次数

使用绑定会破坏 RecyclerView 项目布局

我正在使用 Kotlin 构建 Android 应用程序,并决定替换对 findViewById 的调用并使用绑定。一切正常,但具体来说,当我更改 RecyclerView 的适配器时,它会破坏项目布局。

带有 findViewById 的原始代码:

class WeightListAdapter(val weights: List<WeightWithPictures>, val onWeightItemClickListener: OnWeightItemClickListener) : RecyclerView.Adapter<WeightListAdapter.WeightHolder>()  {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WeightListAdapter.WeightHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.list_item_weight, parent, false)
        return WeightHolder(view)
    }

    override fun onBindViewHolder(holder: WeightListAdapter.WeightHolder, position: Int) {
        val weightWithPictures = weights[position]
        holder.bind(weightWithPictures)
    }

    override fun getItemCount() = weights.size

    inner class WeightHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener {
        private lateinit var weight: Weight
        private val weightValueView: TextView = this.itemView.findViewById(R.id.weightValue)
        private val weightDateView: TextView …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-recyclerview android-binder

1
推荐指数
1
解决办法
981
查看次数