请帮助我.我想将项目名称,数量,金额和费率的数组列表从下达活动确认订单传递到下一个活动确认订单...但是在下一个活动获取该数组列表的空值我能做什么?
订单代码
Intent intent = new Intent(MakeOrder.this,Demo.class);
intent.putStringArrayListExtra("selectedItems",strItemNameAlert);
intent.putStringArrayListExtra("selectedRates",strRateAlert);
intent.putStringArrayListExtra("selectedQuantity",strQuantityAlert);
intent.putStringArrayListExtra("selectedAmount",strAmountAlert);
intent.putStringArrayListExtra("selectedId",strItemIdAlert);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
确认订单的代码
public class ConfirmOrder extends Activity {
ArrayList<String> resultArrItemname;
ArrayList<String> resultArrItemrate;
ArrayList<String> resultArrItemquantity;
ArrayList<String> resultArrItemamount;
ArrayList<String> resultArrItemid;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.demo);
resultArrItemname=new ArrayList<String>();
resultArrItemrate=new ArrayList<String>();
resultArrItemquantity=new ArrayList<String>();
resultArrItemamount=new ArrayList<String>();
resultArrItemid=new ArrayList<String>();
Intent intent1=new Intent();
resultArrItemname = intent1.getStringArrayListExtra("selectedItems");
resultArrItemrate = intent1.getStringArrayListExtra("selectedRates");
resultArrItemquantity = intent1.getStringArrayListExtra("selectedQuantity");
resultArrItemamount = intent1.getStringArrayListExtra("selectedAmount");
resultArrItemid = intent1.getStringArrayListExtra("selectedId");
}
Run Code Online (Sandbox Code Playgroud) 我正试图在我的应用程序中解析json:
所以首先我为我的Android应用程序创建了常量类,它为app.config提供了大约6个变量:
(等级:1)
public class Constants{
// url to make request
public static String url = "http://server.com/";
// JSON Node names
public static final String TAG_CONTACTS = "contacts";
public static final String TAG_ID = "id";
public static final String TAG_NAME = "name";
public static final String TAG_EMAIL = "email";
public static final String TAG_ADDRESS = "address";
public static final String TAG_GENDER = "gender";
}
Run Code Online (Sandbox Code Playgroud)
现在我想在不同的类中使用它,所以我继续创建了不同的类:
(等级:2)
public class ReadFiles{
public void readConstant(){
//appConfig is JSONArray
JSONArray appConfig = null;
// …Run Code Online (Sandbox Code Playgroud) 我按照android 文档编写了一个带有搜索小部件的应用程序.
但我发现有两个ACTION_SEARCH意图发送给了SearchActivity.所以,我怀疑那是我的错.
然后我尝试使用Google Play应用.我输入关键字搜索应用程序,我仍然捕获两个意图!这是logcat.那么,该如何应对呢?即使我用singleTop Activity覆盖onNewIntent,它也需要搜索两次以处理一个搜索操作!
04-18 22:26:19.007:I/ActivityManager(389):从pid 1721 04开始u0 {act = android.intent.action.SEARCH flg = 0x10000000 cmp = com.android.vending/.AssetBrowserActivity(has extras)} -18 22:26:19.007:I/ActivityManager(389):从pid 1721开始u0 {act = android.intent.action.SEARCH flg = 0x10000000 cmp = com.android.vending/.AssetBrowserActivity(has extras)}
我有一个启动Activity的问题.我试图用静态方法开始一个新的活动.
这是我的代码:
static Dialog dialog=null;
public static void NextLevel(Context c,String title,String message){
AlertDialog.Builder alertbox = new AlertDialog.Builder(c);
alertbox.setTitle(title);
alertbox.setMessage(message);
alertbox.setPositiveButton("Volgende level", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
}
});
alertbox.setNegativeButton("Terug naar menu", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
startActivity(new Intent(Main.this, MainMenu.class));
}
});
alertbox.show();
}
Run Code Online (Sandbox Code Playgroud)
startActivity不起作用,因为它无法从静态方法启动Activity.我似乎无法找到解决这个问题的方法,因为我也无法创建一个可以启动它的上下文.
假设我有3个活动.
第一个和第二个都调用Result活动startActivityForResult().在结果中,基于调用活动,我想返回不同的结果.
有没有办法决定哪一个调用了Result Activity并将结果返回给该活动.
我有一个简单的服务,但它似乎没有开始,因为我的两个都没有Log显示logcat
public class MyService extends Service {
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Log.d("ID", "Y");
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
Log.d("S", "Y");
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
}
Run Code Online (Sandbox Code Playgroud)
我把这样的服务称为:
Intent service = new Intent(this, MyService.class);
startService(service);
Run Code Online (Sandbox Code Playgroud)
主要节日是:
<?xml version="1.0" …Run Code Online (Sandbox Code Playgroud) 遇到以下错误的问题
The method getIntent() is undefined for the type
使用以下内容时 extends SherlockFragment {
码
public View onCreateView(LayoutInflater inf, ViewGroup grp, Bundle icicle) {
View v = inf.inflate(R.layout.activity_main, grp, false);
web = (WebView) v.findViewById(R.id.webView);
progressBar = (ProgressBar) v.findViewById(R.id.progressBar1);
Bundle extras = getIntent().getExtras();
String url;
url = extras.getString("url");
setHasOptionsMenu(true);
return v;
Run Code Online (Sandbox Code Playgroud) java android android-intent android-fragments actionbarsherlock
我试图通过电子邮件发送各种条目变量,但我尝试输入多个"额外文本"意图,它只发送指定的最后一个额外文本中的文本.如何获取电子邮件中的所有条目文本?下面是代码:
@Override
public void onClick(View v) {
if (v.getId()==findViewById(R.id.enviar).getId())
{
Intent intentEmail = new Intent(Intent.ACTION_SEND, Uri.fromParts("mailto", "villasantdesign@gmail.com", null));
intentEmail.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"villasantdesign@gmail.com"});
intentEmail.putExtra(Intent.EXTRA_SUBJECT, "Consulta Técnica");
intentEmail.putExtra(Intent.EXTRA_TEXT, etlugar.getText());
intentEmail.putExtra(Intent.EXTRA_TEXT, etfecha.getText());
intentEmail.putExtra(Intent.EXTRA_TEXT, etcable.getText());
intentEmail.putExtra(Intent.EXTRA_TEXT, etqe.getText());
intentEmail.putExtra(Intent.EXTRA_TEXT, etantena.getText());
intentEmail.putExtra(Intent.EXTRA_TEXT, etampli.getText());
intentEmail.putExtra(Intent.EXTRA_TEXT, etmodulo.getText());
intentEmail.setType("message/rfc822");
startActivity(Intent.createChooser(intentEmail, "Enviar"));
}}}
Run Code Online (Sandbox Code Playgroud) 我有一个图像视图,当用户点击它时,它会打开一个包含一些结果的对话框.
但我希望在点击5秒后显示结果.
我想显示空白对话框直到5秒然后我想显示结果?我怎样才能做到这一点 ?非常感谢你.
在我的应用程序上,我发布了一些通知,通知有一个标题和一个文本.当用户单击通知时,我必须打开一个显示标题和通知全文的活动.如果我只有一个通知,它很好,但是如果点击时有2个或更多通知(具有不同的id),我打开活动,使用相同的标题和文本(第一个通知)我如何传递正确的值?抱歉英语不好
public void sendSimpleNotification(String titolo, String testo, String imgUrl, int id) {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this.getApplicationContext());
// Titolo e testo della notifica
notificationBuilder.setContentTitle(titolo);
notificationBuilder.setContentText(testo);
// Testo che compare nella barra di stato non appena compare la notifica
notificationBuilder.setTicker("Nuova offerta dall'Online app");
// Data e ora della notifica
notificationBuilder.setWhen(System.currentTimeMillis());
// Icona della notifica
notificationBuilder.setSmallIcon(R.drawable.ic_notifica);
// Creiamo il pending intent che verrà lanciato quando la notifica
// viene premuta
//System.out.println("definisco l'intent per la notifica");
Intent notificationIntent = new Intent(this.getApplicationContext(), MostraNotifica.class); //eventualmente …Run Code Online (Sandbox Code Playgroud)