本文介绍了应用程序不会故意一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的应用程序code,低于该NTO要意图的一部分,我用调试我觉得行之后不会xmlResponse2 [0] [I] =试验[Ⅰ];西隧我搞错?谁能帮我没有启动任何活动,code后爆发xmlResponse2 [0] [I] =试验[Ⅰ];此行

 公共无效的onReceive(上下文的背景下,意图意图)
{
    // ---得到通过短信---
    捆绑包= intent.getExtras();
    SmsMessage []封邮件= NULL;
    字符串str =;

    如果(捆绑!= NULL)
    {
        // ---检索收到的短信---
        [对象]的PDU =(对象[])bundle.get(的PDU);
        封邮件=新SmsMessage [pdus.length]
        的for(int i = 0; I< msgs.length;我++){
            封邮件[I] = SmsMessage.createFromPdu((字节[])的PDU [I]);
            STR + =短信来自+封邮件[I] .getOriginatingAddress();
            STR + =;
            STR + =封邮件[I] .getMessageBody()的toString()。
            STR + =\ N的;



        的String [] [] xmlResponse2 = NULL;
        的String []测试= str.split(\ N);
        xmlResponse2 =新的String [0] [test.length]
        的for(int i = 0; I< test.length;我++){
            xmlResponse2 [0] [I] =试验[Ⅰ];
             意图L =新的意图(背景下,AgAppMenu.class);
             l.putExtra(味精,xmlResponse2);
             l.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             context.startActivity(升);
        }

        // ---显示新短信---
        Toast.makeText(背景下,海峡,Toast.LENGTH_SHORT).show();
 

解决方案

  xmlResponse2 =新的String [test.length]
    的for(int i = 0; I< test.length;我++){
        xmlResponse2 [I] =试验[Ⅰ];

    }
       意图L =新的意图(背景下,AgAppMenu.class);
         l.putExtra(味精,xmlResponse2);
        // l.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         context.startActivity(升);
 

this is my application code below which nto going to intent part i used debug i find is not going after line xmlResponse2[0][i]=test[i];wht i mistake?? can anyone help me is not launch any activity and code broke after xmlResponse2[0][i]=test[i]; this line

  public void onReceive(Context context, Intent intent) 
{
    //---get the SMS message passed in---
    Bundle bundle = intent.getExtras();        
    SmsMessage[] msgs = null;
    String str = "";  

    if (bundle != null)
    {
        //---retrieve the SMS message received---
        Object[] pdus = (Object[]) bundle.get("pdus");
        msgs = new SmsMessage[pdus.length];            
        for (int i=0; i<msgs.length; i++){
            msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);                
            str += "SMS from " + msgs[i].getOriginatingAddress();                     
            str += " :";
            str += msgs[i].getMessageBody().toString();
            str += "\n";  



        String[][] xmlResponse2= null;
        String[] test = str.split("\n");
        xmlResponse2= new String[0][test.length];
        for (int i = 0; i < test.length; i++) {
            xmlResponse2[0][i]=test[i];
             Intent l = new Intent(context,AgAppMenu.class);
             l.putExtra("msg",xmlResponse2);
             l.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);   
             context.startActivity(l);
        }

        //---display the new SMS message---
        Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
解决方案
 xmlResponse2= new String[test.length];
    for (int i = 0; i < test.length; i++) {
        xmlResponse2[i]=test[i];

    }
       Intent l = new Intent(context,AgAppMenu.class);
         l.putExtra("msg",xmlResponse2);
        // l.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);   
         context.startActivity(l);

这篇关于应用程序不会故意一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 18:39