本文整理汇总了C#中JSONObject.getJSONObject方法的典型用法代码示例。如果您正苦于以下问题:C# JSONObject.getJSONObject方法的具体用法?C# JSONObject.getJSONObject怎么用?C# JSONObject.getJSONObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONObject
的用法示例。
在下文中一共展示了JSONObject.getJSONObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: onReceive
// This onReceive will be call when a OneSignal Background Data Notification is received(before clicking) by the device.
// You can read the additionalData and do anything you need here with it.
// You may consider adding a wake lock here if you need to make sure the devices doesn't go to sleep while processing.
// The following must also be in your AndroidManifest.xml for this to fire:
/*
<receiver
android:name="com.onesignal.example.BackgroundDataBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.onesignal.BackgroundBroadcast.RECEIVE" />
</intent-filter>
</receiver>
Make sure to keep android:exported="false" so other apps can't call can this.
*/
public override void onReceive(Context context, Intent intent)
{
Bundle dataBundle = intent.getBundleExtra("data");
try
{
Log.i("OneSignalExample", "Notification content: " + dataBundle.getString("alert"));
Log.i("OneSignalExample", "Notification title: " + dataBundle.getString("title"));
Log.i("OneSignalExample", "Is Your App Active: " + dataBundle.getBoolean("isActive"));
JSONObject customJSON = new JSONObject(dataBundle.getString("custom"));
if (customJSON.has("a"))
{
Log.i("OneSignalExample", "additionalData: " + customJSON.getJSONObject("a").ToString());
}
}
catch (Exception t)
{
Console.WriteLine(t.ToString());
Console.Write(t.StackTrace);
}
}
示例2: getAccess
public bool getAccess(string verifier)
{
try {
TLog.i (TAG, "Verifier: {0}", verifier);
// this method shouldn't have been called
if (isAuthenticated ())
return false;
if (!requestToken.equals ("") && !requestTokenSecret.equals ("")) {
consumer.setTokenWithSecret (requestToken, requestTokenSecret);
TLog.d (TAG, "Added request token {0} and request token secret {1}", requestToken, requestTokenSecret);
} else
return false;
OAuthProvider provider = getProvider ();
try {
provider.retrieveAccessToken (consumer, verifier);
} catch (OAuthMessageSignerException e1) {
e1.PrintStackTrace ();
return false;
} catch (OAuthNotAuthorizedException e1) {
e1.PrintStackTrace ();
return false;
} catch (OAuthExpectationFailedException e1) {
e1.PrintStackTrace ();
return false;
} catch (OAuthCommunicationException e1) {
e1.PrintStackTrace ();
return false;
}
// access has been granted, store the access token
accessToken = consumer.getToken ();
accessTokenSecret = consumer.getTokenSecret ();
requestToken = "";
requestTokenSecret = "";
try {
JSONObject response = new JSONObject (get (rootApi));
TLog.d (TAG, "Request: {0}", rootApi);
// append a slash to the url, else the signature will fail
userApi = response.getJSONObject ("user-ref").GetString ("api-ref");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.PrintStackTrace ();
}
saveConfiguration ();
TLog.i (TAG, "Got access token {0}.", consumer.getToken ());
} catch (UnknownHostException ex) {
}
return true;
}