2015-05-19 98 views
0

我想使用Parse.com推送网址,并且我添加了一个代码,其中get String显示错误。任何人都可以帮助我!方法getString(字符串)是未定义的类型字符串在Android中

请帮帮我!收到错误

方法的getString(字符串)是不确定的String类型**

package com.example.pushnotificationdemo; 



import org.json.JSONObject; 

import com.example.pushnotificationdemo.R; 
import com.parse.ParseAnalytics; 
import com.parse.ParseInstallation; 
import com.parse.PushService; 

import android.content.Intent; 
import android.net.Uri; 
import android.os.Bundle; 
import android.support.v7.app.ActionBarActivity; 
import android.view.Window; 
import android.webkit.WebChromeClient; 
import android.webkit.WebView; 
import android.webkit.WebViewClient; 



public class MainActivity extends ActionBarActivity { 

    WebView webframe; 



    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     Intent intent = getIntent(); 
     Bundle extras = intent.getExtras(); 
     String jsonData = extras.getString("com.parse.Data"); 
     JSONObject json = new JSONObject(jsonData); 
     String pushStore = json.getString("data"); 
     if(pushStore!=null) { 
      Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(pushStore.getString("url"))); 
      startActivity(browserIntent); 
     } 

     setContentView(R.layout.activity_main); 

     ParseAnalytics.trackAppOpenedInBackground(getIntent()); 

     PushService.setDefaultPushCallback(this, MainActivity.class); 
     ParseInstallation.getCurrentInstallation().saveInBackground(); 



     /** Cerco l'elemento in /res/layout/main.xml */ 
     webframe = (WebView) findViewById(R.id.webview); 

     /** Javascript abilitato (ma non flash) */ 
     webframe.getSettings().setJavaScriptEnabled(true); 



     /** Simulo il webbrowser chrome di android*/ 
     webframe.setWebChromeClient(new WebChromeClient()); 
     webframe.setWebViewClient(new WebViewClient()); 

     /** Assegno l'url di apertura del webframe */ 
     webframe.loadUrl("http://www.dlybugs.com"); 






    } 
} 
+1

你能否发布错误的完整堆栈跟踪,以便我们知道哪些行被错误抛出。 – wattostudios

+0

是的,发布logcat报告。 – theapache64

+0

** pushStore。** getString **(“url”))**,它是什么? – chenzhongpu

回答

0

你从这个代码得到的错误:

pushStore.getString("url") 

因为pushStoreString。这不是JSONObject,你可以拨打getString。你可能需要这个代码:

String pushStore = json.getString("data.url"); 
if(pushStore!=null) { 
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(pushStore)); 
    startActivity(browserIntent); 
} 
相关问题