我正在使用Xtify的项目中工作,而我正在尝试使用getting started示例,但我遇到了问题。该示例不起作用。我在LogCat中得到了这个:错误打开跟踪文件:没有这样的文件或目录(2)
这是我的AndroidManifiest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.projects.xtifyproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<permission android:name="com.projects.xtifyproject.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.projects.xtifyproject.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="com.xtify.sdk.db.Provider"
android:authorities="com.projects.xtifyproject.XTIFY_PROVIDER"
android:exported="false" />
<receiver android:name="com.xtify.sdk.c2dm.C2DMBroadcastReceiver" >
<intent-filter android:permission="com.google.android.c2dm.permission.SEND" >
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.projects.xtifyproject" />
</intent-filter>
<intent-filter android:permission="com.google.android.c2dm.permission.SEND" >
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.projects.xtifyproject" />
</intent-filter>
</receiver>
<receiver android:name="com.xtify.sdk.NotifActionReceiver" />
<receiver android:name="com.xtify.sdk.wi.AlarmReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.xtify.sdk.location.LocationUpdateService" />
<service android:name="com.xtify.sdk.c2dm.C2DMIntentService" />
<service android:name="com.xtify.sdk.alarm.MetricsIntentService" />
<service android:name="com.xtify.sdk.alarm.TagIntentService" />
<service android:name="com.xtify.sdk.alarm.RegistrationIntentService" />
<service android:name="com.xtify.sdk.alarm.LocationIntentService" />
</application>
</manifest>
我的MainActitivy.xml:
package com.projects.xtifyproject;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import com.projects.xtifyproject.R;
import com.xtify.sdk.api.XtifySDK;
public class MainActivity extends Activity {
final String XTIFY_APP_KEY = "aaaa0505-aa00-000a-0a0a-000000a0a000";
final String SENDER_ID = "123412341234"; // This is the Google Project ID
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
XtifySDK.start(getApplicationContext(), XTIFY_APP_KEY, SENDER_ID);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
最后,我的AVD:
问候!
答案 0 :(得分:3)
public class SplashScreen extends Activity {
private static final String XTIFY_APP_KEY = "xyz";
private static final String PROJECT_NUM = "xyz";
@Override
protected void onStart() {
super.onStart();
XtifySDK.start(getApplicationContext(), XTIFY_APP_KEY, PROJECT_NUM);
XtifySDK.enableNotification(getApplicationContext());
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splashscreen);
// xtify notification
NotificationsPreference.setSoundEnabled(getApplicationContext(), true);
NotificationsPreference.setSound(getApplicationContext(),
R.raw.notification_sound);
NotificationsPreference
.setVibrateEnabled(getApplicationContext(), true);
long[] vibrate = { 0, 100, 200, 300 };
NotificationsPreference.setVibrationPattern(getApplicationContext(),
vibrate);
NotificationsPreference.setIcon(getApplicationContext(),
R.drawable.icon);
NotificationsPreference.setLightsEnabled(getApplicationContext(), true);
int ledARGB = 0x00a2ff;
int ledOnMS = 300;
int ledOffMS = 1000;
NotificationsPreference.setLights(getApplicationContext(), new int[] {
ledARGB, ledOnMS, ledOffMS });
}
}
答案 1 :(得分:0)
Xtify SDK使用Google GCM服务。我建议使用实际设备进行测试。如果它不可用,您可以使用Google API等级8或更高版本创建模拟器,当您运行模拟器时,请确保转到设置屏幕并添加有效的Google帐户(GCM服务需要才能在设备上运行)。
您还可以查看具有onError方法的Xtify Notifier,该方法将在SDK中发生错误时被调用。