我正在使用Cordova 6.0。 我正在为iOS开发。 我正在使用XCode 7.3。
我的widget指定如此config.xml:
package com.projects.activities;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.libraries.usersession.UserAccessSession;
import com.libraries.usersession.UserSession;
import com.projects.storefinder.R;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
/**
* Created by Ygor on 23/02/2016.
*/
public class FinalizarPedido extends Activity {
private TextView tvDescricao;
private TextView tvQuantidade;
private String Descricao;
private String Unidade;
private String Categoria;
private String Qtd;
private String pedidos_nome;
private String pedidos_email;
private String pedidos_id;
private AlertDialog alerta;
String user_id;
InputStream is=null;
String result=null;
String line=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.finaliza_pedido);
Button novoPedido = (Button) findViewById(R.id.novo_pedido);
Button btnEnd = (Button) findViewById(R.id.buttonFim);
new select().execute();
btnEnd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(FinalizarPedido.this, FormPedidos.class);
startActivity(intent);
}
});
novoPedido.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(FinalizarPedido.this, InsertNewPedidos.class);
startActivity(intent);
}
});
}
class select extends AsyncTask<String, Integer, String> {
private StringBuilder sb;
private ProgressDialog pr;
private HttpResponse req;
private InputStream is;
@Override
protected void onPreExecute() {
super.onPreExecute();
Toast.makeText(getApplicationContext(), "Captando ...", Toast.LENGTH_LONG).show();
}
@Override
protected String doInBackground(String... arg0) {
ArrayList<String> pedidos_nome = new ArrayList<String>();
ArrayList<String> pedidos_id = new ArrayList<String>();
ArrayList<String> pedidos_email = new ArrayList<String>();
UserAccessSession userAccess = UserAccessSession.getInstance(FinalizarPedido.this);
UserSession userSession = userAccess.getUserSession();
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("user_id", String.valueOf(userSession.getUser_id())));
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://marketingdigitalabc.com.br/buysell/pedidos_show.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
Log.e("pass 1", "connection success ");
} catch (Exception e) {
Log.e("Fail 1", e.toString());
Toast.makeText(getApplicationContext(), "Invalid IP Address",
Toast.LENGTH_LONG).show();
}
try {
BufferedReader reader = new BufferedReader
(new InputStreamReader(is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result = sb.toString();
Log.e("pass 2", "connection success ");
} catch (Exception e) {
Log.e("Fail 2", e.toString());
}
try {
JSONObject json_data = new JSONObject(result);
JSONArray arr = json_data.getJSONArray("message");
for (int i=0; i < arr.length(); i++) {
JSONObject json_dat = arr.getJSONObject(i);
pedidos_nome.add((json_dat.getString("pedidos_nome")));
pedidos_id.add((json_dat.getString("pedidos_id")));
pedidos_email.add((json_dat.getString("pedidos_email")));
pedidos_nome.get(i);
pedidos_id.get(i);
pedidos_email.get(i);
}
} catch (Exception e) {
Log.e("Fail 3", e.toString());
}
return user_id;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
String[] lista = {"Produtos:" +pedidos_id};
final ListView listaPedido = (ListView) findViewById(R.id.lista);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(FinalizarPedido.this, android.R.layout.simple_list_item_1, lista);
listaPedido.setAdapter(adapter);
listaPedido.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> lista, View item, int posicao, long id) {
listaPedido.getItemAtPosition(posicao);
AlertDialog.Builder builder = new AlertDialog.Builder(FinalizarPedido.this);//Cria o gerador do AlertDialog
builder.setTitle("Pedido: " + pedidos_nome);
builder.setMessage("Pedido id: " + pedidos_id + "\nPedido E-mail: " + pedidos_email+ "\nPedido Nome: " + pedidos_nome);
builder.setNegativeButton("Fechar", null);
alerta = builder.create();
alerta.show();
}
});
}
}
}
出于某种原因,当我运行<widget id="io.cordova.hellocordova" version="2.0.0" ios-CFBundleVersion="2.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
命令时,它会将XCode中的包和版本设置为cordova prepare ios
而不是0.0.1
。
如何解决此问题,以便设置正确的版本号。