2015-05-19 94 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); 
} 
相關問題