gpt4 book ai didi

java - Quickblox: sample 不会开始

转载 作者:行者123 更新时间:2023-11-29 21:16:49 28 4
gpt4 key购买 nike

所以我正在尝试运行 Quickblox sample chatXMPP Sample Chat .

我将 Eclipse 与最新的 Android sdk/build 一起使用。

导入示例后,按照 Quickblox 指南的说明,我在代码中出现了一些错误,但不多于缺少一些导入,但是当我尝试运行该应用程序时出现错误,应用程序安装正确,但在错误开始出现在 Logcat 上之后。

public class SplashActivity extends Activity implements QBCallback {

private static final String APP_ID = "6445";
private static final String AUTH_KEY = "9a4bnSXbP-KN9G8";
private static final String AUTH_SECRET = "FwunQpKdkE2e7AJ";

private ProgressBar progressBar;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);



progressBar = (ProgressBar) findViewById(R.id.progressBar);

QBSettings.getInstance().fastConfigInit(APP_ID, AUTH_KEY, AUTH_SECRET);
QBAuth.createSession(this);
}

@Override
public void onComplete(Result result) {
progressBar.setVisibility(View.GONE);

if (result.isSuccess()) {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
} else {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setMessage("Error(s) occurred. Look into DDMS log for details, " +
"please. Errors: " + result.getErrors()).create().show();
}
}

@Override
public void onComplete(Result result, Object context)
{
}
}
public class MainActivity extends ActionBarActivity implements ActionBar.TabListener {

private static final int AUTHENTICATION_REQUEST = 1;
private static final int POSITION_USER = 0;
private static final int POSITION_ROOM = 1;
private SectionsPagerAdapter sectionsPagerAdapter;
private ViewPager viewPager;
private Action lastAction;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

List<Fragment> tabs = new ArrayList<Fragment>();
tabs.add(UsersFragment.getInstance());
tabs.add(RoomsFragment.getInstance());

sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), tabs);

viewPager = (ViewPager) findViewById(R.id.pager);
viewPager.setAdapter(sectionsPagerAdapter);

viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});

for (int i = 0; i < sectionsPagerAdapter.getCount(); i++) {
actionBar.addTab(actionBar.newTab()
.setText(sectionsPagerAdapter.getPageTitle(i))
.setTabListener(this));
}
}

@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
int position = tab.getPosition();
QBUser qbUser = ((App) getApplication()).getQbUser();
if (qbUser != null) {
viewPager.setCurrentItem(position);

} else if (position == POSITION_ROOM) {
lastAction = Action.ROOM_LIST;
showAuthenticateDialog();
}
}

@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

}

@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (lastAction) {
case CHAT:
((UsersFragment) sectionsPagerAdapter.getItem(POSITION_USER)).startChat();
break;
case ROOM_LIST:
viewPager.setCurrentItem(POSITION_ROOM);
break;
}
((RoomsFragment) sectionsPagerAdapter.getItem(POSITION_ROOM)).loadRooms();
} else {
showUsersFragment();
}
}

private void showUsersFragment() {
getSupportActionBar().selectTab(getSupportActionBar().getTabAt(POSITION_USER));
viewPager.setCurrentItem(POSITION_USER);
}

public void setLastAction(Action lastAction) {
this.lastAction = lastAction;
}

public void showAuthenticateDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Authorize first");
builder.setItems(new String[]{"Login", "Register"}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
Intent intent = new Intent(MainActivity.this, LoginActivity.class);
startActivityForResult(intent, AUTHENTICATION_REQUEST);
break;
case 1:
intent = new Intent(MainActivity.this, RegistrationActivity.class);
startActivityForResult(intent, AUTHENTICATION_REQUEST);
break;
}
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
showUsersFragment();
}
});
builder.show();
}

public static enum Action {CHAT, ROOM_LIST}

public static class SectionsPagerAdapter extends FragmentPagerAdapter {

private List<Fragment> fragments;

public SectionsPagerAdapter(FragmentManager fm, List<Fragment> fragments) {
super(fm);
this.fragments = fragments;
}

@Override
public Fragment getItem(int position) {
return fragments.get(position);
}

@Override
public int getCount() {
return fragments.size();
}

@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case POSITION_USER:
return "Users";
case POSITION_ROOM:
return "Rooms";
}
return null;
}
}}

我的 list 文件是:

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.quickblox.sample.chat"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".App"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.quickblox.sample.chat.ui.activities.SplashActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.activities.MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAINMENU" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".ui.activities.ChatActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".ui.activities.LoginActivity"
android:label="Login" />
<activity
android:name=".ui.activities.RegistrationActivity"
android:label="Registration" />
</application>

</manifest>

这是我的错误信息:

FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.quickblox.sample.chat/com.quickblox.sample.chat.ui.activities.SplashActivity}: java.lang.ClassNotFoundException: com.quickblox.sample.chat.ui.activities.SplashActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)

最佳答案

打开Properties->Java Build Path->Order and Export,勾选QB jar library。根据日志,您尚未将其添加到构建中。

关于java - Quickblox: sample 不会开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21200192/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com