Here is my code. I have built webview for youtube and using WebChromClient tried to add full screen feature on app. But when clicked on fullscreen it gives blank screen and auido is played in back ground.
MainAvtivity
public class MainActivity extends AppCompatActivity {
public WebView mywebview;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mywebview = (WebView)findViewById(R.id.youtube_webview);
WebSettings webSettings =mywebview.getSettings();
webSettings.setJavaScriptEnabled(true);
mywebview.setWebChromeClient(new CrmClient());
mywebview.setWebViewClient(new WebViewClient());
mywebview.getSettings().setJavaScriptEnabled(true);
mywebview.setVerticalScrollBarEnabled(false);
mywebview.setHorizontalScrollBarEnabled(false);
mywebview.loadUrl("https://www.youtube.com");
}
class CrmClient extends WebChromeClient{
#Override
public void onShowCustomView(View view, CustomViewCallback callback) {
super.onShowCustomView(view, callback);
}
#Override
public void onHideCustomView() {
super.onHideCustomView();
}
}
#Override
protected void onPause() {
super.onPause();
if(mywebview != null) {
mywebview.onPause();
mywebview.pauseTimers();
}
}
#Override
protected void onResume() {
super.onResume();
if(mywebview != null){
mywebview.onResume();
mywebview.resumeTimers();
}
}
#Override
public void onBackPressed() {
if (mywebview.canGoBack())
mywebview.goBack();
else
super.onBackPressed();
}
Activity_main.XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity">
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/youtube_webview" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</FrameLayout>
</WebView>
AndroidMainFest.XML
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name=".MainActivity"
android:configChanges="orientation|screenSize"
android:label="#string/app_name">
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
try this code
public class MainActivity extends AppCompatActivity {
public WebView mywebview;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mywebview = (WebView)findViewById(R.id.youtube_webview);
WebSettings webSettings =mywebview.getSettings();
webSettings.setJavaScriptEnabled(true);
mywebview.setWebViewClient(new WebViewClient());
mywebview.getSettings().setJavaScriptEnabled(true);
mywebview.setVerticalScrollBarEnabled(false);
mywebview.setHorizontalScrollBarEnabled(false);
mywebview.loadUrl("https://www.youtube.com");
mywebview.setWebChromeClient(new WebChromeClient() {
public void onShowCustomView(View view,
WebChromeClient.CustomViewCallback callback) {
if (mCustomView != null) {
onHideCustomView();
return;
}
mCustomView = view;
mOriginalSystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility();
mOriginalOrientation = getRequestedOrientation();
mCustomViewCallback = callback;
FrameLayout decor = (FrameLayout) getWindow().getDecorView();
decor.addView(mCustomView, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_IMMERSIVE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
#Override
public void onHideCustomView() {
// 1. Remove the custom view
FrameLayout decor = (FrameLayout) getWindow().getDecorView();
decor.removeView(mCustomView);
mCustomView = null;
// 2. Restore the state to it's original form
getWindow().getDecorView()
.setSystemUiVisibility(mOriginalSystemUiVisibility);
setRequestedOrientation(mOriginalOrientation);
mCustomViewCallback.onCustomViewHidden();
mCustomViewCallback = null;
}
});
}
and add this
private View mCustomView;
private int mOriginalSystemUiVisibility;
private int mOriginalOrientation;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
protected FrameLayout mFullscreenContainer;
try this code
private class MyChrome extends WebChromeClient {
private View mCustomView;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
protected FrameLayout mFullscreenContainer;
private int mOriginalOrientation;
private int mOriginalSystemUiVisibility;
MyChrome() {}
public Bitmap getDefaultVideoPoster()
{
if (mCustomView == null) {
return null;
}
return BitmapFactory.decodeResource(getApplicationContext().getResources(), 2130837573);
}
public void onHideCustomView()
{
((FrameLayout)getWindow().getDecorView()).removeView(this.mCustomView);
this.mCustomView = null;
getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
setRequestedOrientation(this.mOriginalOrientation);
this.mCustomViewCallback.onCustomViewHidden();
this.mCustomViewCallback = null;
}
public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback paramCustomViewCallback)
{
if (this.mCustomView != null)
{
onHideCustomView();
return;
}
this.mCustomView = paramView;
this.mOriginalSystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility();
this.mOriginalOrientation = getRequestedOrientation();
this.mCustomViewCallback = paramCustomViewCallback;
((FrameLayout)getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1));
getWindow().getDecorView().setSystemUiVisibility(3846);
}
}
and add this code
myWebView.setWebChromeClient(new MyChrome());
Related
I created a simple webview app that displays an error.html from assets when there is no network, but users cannot continue with webview once network is available. users are simply stuck in the error.html page. what i have been trying to do now is to make the webview app to check for network and display "no internet connection" if there is none and also reload when network is available.
Manifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mary">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Light">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Splash"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.java
private WebView mWebView;
SwipeRefreshLayout swipe;
private void setFullScreen() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
);
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
swipe = (SwipeRefreshLayout) findViewById(R.id.swipe);
swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
#Override
public void onRefresh() {
LoadWeb(mWebView.getUrl());
}
});
LoadWeb("http://m.mary.org");
}
public void LoadWeb(String url){
mWebView = (WebView) findViewById(R.id.activity_main_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl(url);
swipe.setRefreshing(true);
mWebView.setDownloadListener(new DownloadListener() {
#Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
DownloadManager.Request myRequest = new DownloadManager.Request(Uri.parse(url));
myRequest.allowScanningByMediaScanner();
myRequest.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
DownloadManager myManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
myManager.enqueue(myRequest);
Toast.makeText(MainActivity.this, "Your File is downloading....", Toast.LENGTH_SHORT).show();
}});
mWebView.setWebViewClient(new com.example.mary.MyAppWebViewClient(){
public void onReceivedError(WebView view, int errorCode, String description,String failingUrl) {
mWebView.loadUrl("file:///android_asset/error.html");
}
public void onPageFinished(WebView view, String url) {
//hide loading image
swipe.setRefreshing(false);
//show webview
findViewById(R.id.activity_main_webview).setVisibility(View.VISIBLE);
}});
}
#Override
public void onBackPressed() {
if(mWebView.canGoBack()) {
mWebView.goBack();
} else {
super.onBackPressed();
}
}
}
MyAppWebViewClient.java
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(Uri.parse(url).getHost().endsWith("m.mary.org")) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
view.getContext().startActivity(intent);
return true;
}
create a broadcast receiver :
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import java.util.HashSet;
import java.util.Set;
public class NetworkStateReceiver extends BroadcastReceiver {
protected Set<NetworkStateReceiverListener> listeners;
protected Boolean connected;
public NetworkStateReceiver() {
listeners = new HashSet<NetworkStateReceiverListener>();
connected = null;
}
public void onReceive(Context context, Intent intent) {
if(intent == null || intent.getExtras() == null)
return;
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = manager.getActiveNetworkInfo();
if(ni != null && ni.getState() == NetworkInfo.State.CONNECTED) {
connected = true;
} else if(intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,Boolean.FALSE)) {
connected = false;
}
notifyStateToAll();
}
private void notifyStateToAll() {
for(NetworkStateReceiverListener listener : listeners)
notifyState(listener);
}
private void notifyState(NetworkStateReceiverListener listener) {
if(connected == null || listener == null)
return;
if(connected == true)
listener.networkAvailable();
else
listener.networkUnavailable();
}
public void addListener(NetworkStateReceiverListener l) {
listeners.add(l);
notifyState(l);
}
public void removeListener(NetworkStateReceiverListener l) {
listeners.remove(l);
}
public interface NetworkStateReceiverListener {
public void networkAvailable();
public void networkUnavailable();
}
}
in your activity use it like this :
private NetworkStateReceiver.NetworkStateReceiverListener networkStateReceiverListener = new NetworkStateReceiver.NetworkStateReceiverListener() {
#Override
public void networkAvailable() {
//todo: refresh webview
}
#Override
public void networkUnavailable() {
//todo: show error
}
};
permission in manifest:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I have 3 Activity. 1 - MainActivity , 2 - InfoActivity, 3 - ChangelogActivity.
If i am located on InfoActivity all is good (on InfoActivity placed ProgressBar) , if i go to ChangelogActivity and go back again to InfoActivity ProgressBar work fine, and his value not 0, but if i go to MainActivity from InfoActivity and go back, now ProgerssBar get value 0.
How i can fix it?
If need i can place some code here.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.teammt.gmanrainy.huaweifirmwarefinder">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden|uiMode">
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=".FirmwareInfo"
android:configChanges="orientation|screenSize|keyboardHidden|uiMode"
android:screenOrientation="portrait" />
<activity
android:name=".FirmwareChangelog"
android:configChanges="orientation|screenSize|keyboardHidden|uiMode"
android:screenOrientation="portrait" />
<activity android:name=".SettingsActivity"
android:configChanges="orientation|screenSize|keyboardHidden|uiMode"
android:screenOrientation="portrait"></activity>
</application>
</manifest>
MainActivity Overrided Methods
//Действия во время созданиея MainActivity
#Override
protected void onCreate(Bundle savedInstanceState) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
//Конструктор Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Проверка прав
ActivityCompat.requestPermissions(this, PERMISSION_STRING_ARRAY, REQUEST_PERMISSION_PHONE_STATE);
//Инициализация
utils = new FFUtils();
gridView = (GridView) findViewById(R.id.firmware_grid_view);
//Установка модели в тайтл
if(deviceModel != null)
setTitle(deviceModel);
else
setTitle(getString(R.string.app_name));
///////////////////////////////////////
// Advanced listener блок
///////////////////////////////////////
//Клик по элементу GridView
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
try
{
System.out.println(lastFirmwares.get(position));
String[] lastFirmwareArray = lastFirmwares.get(position).split("\\|");
Intent intent = new Intent(getThis(), FirmwareInfo.class);
intent.putExtra("firmwareName",lastFirmwareArray[0]).
putExtra("firmwareType",lastFirmwareArray[1]).
putExtra("firmwareLink",lastFirmwareArray[2]).
putExtra("firmwareSize",lastFirmwareArray[3]).
putExtra("firmwareLastmod",lastFirmwareArray[4]).
putExtra("firmwareCount",lastFirmwares.size()).
putExtra("firmwareId",position);
startActivity(intent);
}
catch (Exception ex)
{
Log.e("GetFirmwarePosition",ex.getMessage());
}
}
});
}
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
#Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBundle("newBundy", newBundy);
}
#Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
savedInstanceState.getBundle("newBundy");
}
//Действия после загрузки формы
#Override
protected void onStart() {
super.onStart();
getDelegate().onStart();
//Получаем список моделей
modelsList = utils.getModelsList(MODELSLIST_LINK);
//Получаем приведенную к общему виду модель
if(modelManuallyChanged == false)
deviceModel = utils.getDeviceModel(modelsList,utils.getDeviceFullModel());
//Добавляем модель в тайтл
setTitle(deviceModel);
}
InfoActivity Overrided Methods
//Действия во время созданиея FirmwareInfo
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_firmware_info);
this.setTitle("FirmwareInfo");
//Инициализация
utils = new FFUtils();
firmware_info_lastmod_textview = (TextView)findViewById(R.id.firmware_info_lastmod_textview);
firmware_info_size_textview = (TextView) findViewById(R.id.firmware_info_size_textview);
firmware_info_download_progressbar = (ProgressBar) findViewById(R.id.firmware_info_download_progressbar);
//firmware_info_download_progressbar.setProgress(0);
//Убираем тень
getSupportActionBar().setElevation(0);
}
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
#Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putInt("progressbar_progress", firmware_info_download_progressbar.getProgress());
}
#Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
int progressbar_progress = savedInstanceState.getInt("progressbar_progress");
firmware_info_download_progressbar.setProgress(progressbar_progress);
}
//Действия после загрузки формы
#Override
protected void onStart() {
super.onStart();
getDelegate().onStart();
firmwareName = getIntent().getExtras().getString("firmwareName");
firmwareType = getIntent().getExtras().getString("firmwareType");
firmwareLink = getIntent().getExtras().getString("firmwareLink");
firmwareSize = getIntent().getExtras().getString("firmwareSize");
firmwareLastmod = getIntent().getExtras().getString("firmwareLastmod");
firmwareId = getIntent().getExtras().getInt("firmwareId");
firmwareCount = getIntent().getExtras().getInt("firmwareCount");
if(firmwareName != null)
{
setTitle(firmwareName + " " + firmwareType);
firmware_info_lastmod_textview.setText(getString(R.string.last_mod) + " " + firmwareLastmod);
firmware_info_size_textview.setText(getString(R.string.size) + " " + utils.convertToMegabyte(firmwareSize));
}
}
Changelog Overrided Methods
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_firmware_changelog);
//Инициализация
utils = new FFUtils();
firmware_changelog_view_model = (TextView)findViewById(R.id.firmware_changelog_view_model);
firmware_changelog_view_changelog = (TextView)findViewById(R.id.firmware_changelog_view_changelog);
firmware_changelog_view_changelog.setMovementMethod(new ScrollingMovementMethod());
//Убираем тень
getSupportActionBar().setElevation(0);
//Убираем Titile
getSupportActionBar().hide();
}
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}#Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBundle("newBundy", newBundy);
}
#Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
savedInstanceState.getBundle("newBundy");
}
//Действия после загрузки формы
#Override
protected void onStart() {
super.onStart();
getDelegate().onStart();
firmwareName = getIntent().getExtras().getString("firmwareName");
firmwareType = getIntent().getExtras().getString("firmwareType");
firmwareLink = getIntent().getExtras().getString("firmwareLink");
firmwareSize = getIntent().getExtras().getString("firmwareSize");
firmwareLastmod = getIntent().getExtras().getString("firmwareLastmod");
firmware_changelog_view_model.setText(firmwareName);
Thread t = new Thread(new Runnable() {
#Override
public void run() {
try
{
//Получаем List со всеми строками feature из changelog
parsedChangelog = parseXmlString(prepareXpp(utils.getXmlFromUrl(firmwareLink.replace("update.zip","changelog.xml"))));
}
catch (Exception ex)
{
Log.e("Parse error",ex.getMessage());
}
StringBuilder sb = new StringBuilder();
for (String s : parsedChangelog)
{
sb.append(s);
sb.append("\t");
}
utils.universalSetText(firmware_changelog_view_changelog,sb.toString());
//firmware_changelog_view_changelog.setText(sb.toString());
}
});
t.start();
}
I tried to change my Launcher Activity in my Manifest file. After changing it, I went reseted my code of again (re-edited so that it was the same as before). So I just copy pasted this code between my activities
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
After reseting my code the app won't open.
I got an error
java.lang.IllegalArgumentException: AppCompat does not support the current theme features, poiting out on my setContentView(R.layout.activity_main);
I got really frustrated by this problem cause I didn't change anything in my code (it is excaclty as it used to be when it was working)
Here is my manifest file code
<manifest package="com.inthessaloniki.cityguide"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">
<!-- versionCode, versionName, minSdkVersion, targetSdkVersion properties are set via Gradle script -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- allows the API to access Google web-based services -->
<!-- maps API needs OpenGL ES 2.0 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="false"/>
<!--
You can easily change the main theme. Just modify application.android:theme attribute.
There are 8 main themes you can use:
Theme.CityGuide.Blue
Theme.CityGuide.Brown
Theme.CityGuide.Carrot
Theme.CityGuide.Gray
Theme.CityGuide.Green
Theme.CityGuide.Indigo
Theme.CityGuide.Red
Theme.CityGuide.Yellow
Don't forget to modify also MainActivity's theme.
-->
<application
android:name=".CityGuideApplication"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.CityGuide.Indigo"
tools:replace="android:icon">
<!--
Themes for MainActivity:
Theme.CityGuide.TransparentStatusBar.Blue
Theme.CityGuide.TransparentStatusBar.Brown
Theme.CityGuide.TransparentStatusBar.Carrot
Theme.CityGuide.TransparentStatusBar.Gray
Theme.CityGuide.TransparentStatusBar.Green
Theme.CityGuide.TransparentStatusBar.Indigo
Theme.CityGuide.TransparentStatusBar.Red
Theme.CityGuide.TransparentStatusBar.Yellow
-->
<activity
android:name=".activity.MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.CityGuide.TransparentStatusBar.Indigo"
android:launchMode="standard">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.PoiDetailActivity"
android:label="#string/title_poi_detail"
android:launchMode="standard"/>
<activity
android:name=".activity.TourDetailActivity"
android:label="#string/title_tour_detail"
android:launchMode="standard"/>
<activity
android:name=".activity.MapActivity"
android:label="#string/title_map"
android:launchMode="standard"/>
<activity
tools:replace="android:configChanges"
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|smallestScreenSize"/>
<activity
android:name=".activity.DescriptionDetailsActivity"
android:label="#string/title_activity_description_details"
android:theme="#style/Theme.CityGuide.TransparentStatusBar.Indigo">
</activity>
<activity
android:name=".activity.MailFormActivity"
android:label="#string/title_tour_detail"
android:theme="#style/Theme.CityGuide.TransparentStatusBar.Indigo">
</activity>
<provider
android:name=".content.PoiSearchRecentSuggestionsProvider"
android:authorities="com.inthessaloniki.cityguide.content.PoiSearchRecentSuggestionsProvider"
android:exported="false"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="#xml/analytics_global_tracker"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/maps_api_key"/>
</application>
Main Activity Code
public class MainActivity extends AppCompatActivity implements DrawerAdapter.CategoryViewHolder.OnItemClickListener, OnSearchListener
{
private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mDrawerToggle;
private ScrimInsetsFrameLayout mDrawerScrimInsetsFrameLayout;
private DrawerAdapter mDrawerAdapter;
private CharSequence mTitle;
private CharSequence mDrawerTitle;
private List<CategoryModel> mCategoryList;
public static Intent newIntent(Context context)
{
Intent intent = new Intent(context, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
return intent;
}
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupActionBar();
setupRecyclerView();
setupDrawer(savedInstanceState);
// init analytics tracker
((CityGuideApplication) getApplication()).getTracker();
}
#Override
public void onStart()
{
super.onStart();
// analytics
GoogleAnalytics.getInstance(this).reportActivityStart(this);
}
#Override
public void onResume()
{
super.onResume();
}
#Override
public void onPause()
{
super.onPause();
}
#Override
public void onStop()
{
super.onStop();
// analytics
GoogleAnalytics.getInstance(this).reportActivityStop(this);
}
#Override
public void onDestroy()
{
super.onDestroy();
}
#Override
public boolean onOptionsItemSelected(MenuItem item)
{
// open or close the drawer if home button is pressed
if(mDrawerToggle.onOptionsItemSelected(item))
{
return true;
}
// action bar menu behaviour
switch(item.getItemId())
{
default:
return super.onOptionsItemSelected(item);
}
}
#Override
protected void onPostCreate(Bundle savedInstanceState)
{
super.onPostCreate(savedInstanceState);
mDrawerToggle.syncState();
}
#Override
public void onConfigurationChanged(Configuration newConfiguration)
{
super.onConfigurationChanged(newConfiguration);
mDrawerToggle.onConfigurationChanged(newConfiguration);
}
#Override
public void setTitle(CharSequence title)
{
mTitle = title;
getSupportActionBar().setTitle("");
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/nexa-bold.otf");
final TextView toolbarName = (TextView) findViewById(R.id.toolbar_title);
toolbarName.setText(mTitle);
}
#Override
public void onItemClick(View view, int position, long id, int viewType)
{
// position
int categoryPosition = mDrawerAdapter.getCategoryPosition(position);
selectDrawerItem(categoryPosition);
}
#Override
public void onSearch(String query)
{
Fragment fragment = PoiListFragment.newInstance(query);
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.activity_main_container, fragment).commitAllowingStateLoss();
mDrawerAdapter.setSelected(mDrawerAdapter.getRecyclerPositionByCategory(0));
setTitle(getString(R.string.title_search) + ": " + query);
}
private void setupActionBar()
{
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar bar = getSupportActionBar();
bar.setDisplayUseLogoEnabled(false);
bar.setDisplayShowTitleEnabled(true);
bar.setDisplayShowHomeEnabled(true);
bar.setDisplayHomeAsUpEnabled(true);
bar.setHomeButtonEnabled(true);
}
private void setupRecyclerView()
{
// reference
RecyclerView recyclerView = getRecyclerView();
// set layout manager
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(linearLayoutManager);
// load categories from database
loadCategoryList();
// set adapter
if(recyclerView.getAdapter()==null)
{
// create adapter
mDrawerAdapter = new DrawerAdapter(mCategoryList, this);
}
else
{
// refill adapter
mDrawerAdapter.refill(mCategoryList, this);
}
recyclerView.setAdapter(mDrawerAdapter);
// add decoration
List<Integer> dividerPositions = new ArrayList<>();
dividerPositions.add(3);
RecyclerView.ItemDecoration itemDecoration = new DrawerDividerItemDecoration(
this,
null,
dividerPositions,
getResources().getDimensionPixelSize(R.dimen.global_spacing_xxs));
recyclerView.addItemDecoration(itemDecoration);
}
private void setupDrawer(Bundle savedInstanceState)
{
mTitle = getTitle();
mDrawerTitle = getTitle();
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/nexa-bold.otf");
final TextView toolbarName = (TextView) findViewById(R.id.toolbar_title);
toolbarName.setText(mTitle);
toolbarName.setTypeface(typeface);
// reference
mDrawerLayout = (DrawerLayout) findViewById(R.id.activity_main_layout);
mDrawerScrimInsetsFrameLayout = (ScrimInsetsFrameLayout) findViewById(R.id.activity_main_drawer);
// set drawer
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
mDrawerLayout.setStatusBarBackgroundColor(ResourcesHelper.getValueOfAttribute(this, R.attr.colorPrimaryDark));
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close)
{
#Override
public void onDrawerClosed(View view)
{
toolbarName.setText(mTitle);
getSupportActionBar().setTitle("");
supportInvalidateOptionsMenu();
}
#Override
public void onDrawerOpened(View drawerView)
{
toolbarName.setText(mTitle);
getSupportActionBar().setTitle("");
supportInvalidateOptionsMenu();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
// show initial fragment
if(savedInstanceState == null)
{
selectDrawerItem(0);
}
}
private void selectDrawerItem(int position)
{
long mCategoryId = mCategoryList.get(position).getId();
Fragment fragment = null;
if(mCategoryId==PoiListFragment.CATEGORY_ID_ALL || mCategoryId==PoiListFragment.CATEGORY_ID_FAVORITES ){
fragment = PoiListFragment.newInstance(mCategoryId);
}else{
fragment = SubCategoryListFragment.newInstance(mCategoryId);
}
FragmentManager fragmentManager = getSupportFragmentManager();
String categoryName = mCategoryList.get(position).getName();
fragmentManager.beginTransaction().replace(R.id.activity_main_container, fragment, categoryName).addToBackStack(categoryName).commitAllowingStateLoss();
mDrawerAdapter.setSelected(mDrawerAdapter.getRecyclerPositionByCategory(position));
setTitle(categoryName);
mDrawerLayout.closeDrawer(mDrawerScrimInsetsFrameLayout);
}
public void showPOIFragment(long categoryId, String categoryName){
PoiListFragment fragment = PoiListFragment.newInstance(categoryId);
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.activity_main_container, fragment, categoryName).addToBackStack(categoryName).commitAllowingStateLoss();
if (!TextUtils.isEmpty(categoryName)){
setTitle(categoryName);
}
}
public void showSubCategoryFragment(long categoryId, String categoryName){
SubCategoryListFragment fragment = SubCategoryListFragment.newInstance(categoryId);
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.activity_main_container, fragment, categoryName).addToBackStack(categoryName).commitAllowingStateLoss();
if (!TextUtils.isEmpty(categoryName)){
setTitle(categoryName);
}
}
private void loadCategoryList()
{
try
{
mCategoryList = CategoryDAO.readAll(-1l, -1l);
}
catch(SQLException e)
{
e.printStackTrace();
}
CategoryModel Thessaloniki = new CategoryModel();
Thessaloniki.setId(PoiListFragment.CATEGORY_ID_THESSALONIKI);
Thessaloniki.setName("Thessaloniki");
Thessaloniki.setImage("drawable://" + R.drawable.ic_category_all);
CategoryModel all = new CategoryModel();
all.setId(PoiListFragment.CATEGORY_ID_ALL);
all.setName(getResources().getString(R.string.drawer_category_all));
all.setImage("drawable://" + R.drawable.ic_category_all);
CategoryModel favorites = new CategoryModel();
favorites.setId(PoiListFragment.CATEGORY_ID_FAVORITES);
favorites.setName(getResources().getString(R.string.drawer_category_favorites));
favorites.setImage("drawable://" + R.drawable.ic_category_favorites);
mCategoryList.add(0,Thessaloniki);
mCategoryList.add(1, all);
mCategoryList.add(2, favorites);
}
private RecyclerView getRecyclerView()
{
return (RecyclerView) findViewById(R.id.activity_main_drawer_recycler);
}
#Override
public void onBackPressed() {
int count = getSupportFragmentManager().getBackStackEntryCount();
if (count == 1) {
finish();
}else{
getSupportFragmentManager().popBackStack();
String name = getSupportFragmentManager().getBackStackEntryAt(count-2).getName();
setTitle(name);
}
// super.onBackPressed();
}
}
I had face similar issue when i had firstly created project in android stdio with API 23 so for fixing these issue try to do some changes.
Please change your activity code first line :-
public class MainActivity extends AppCompatActivity
to these :-
public class MainActivity extends Activity
It had worked for me when i was in same problem.
Is there anyway of showing only my webview once loading has complete? at the moment i have a little webview Fragment on my homescreen but it takes a while to load.I want to show only once loading completes because at the moment its a white screen until loading completes.This does not look the greatest. I tried to add a progress bar but for some reason that does not work in my fragment either.
Ive tried to add the code posted as an answer but it makes no difference. i think its because it a fragment that im having the issues as the progress par works in my main activity webviews.
public class WebViewFragment extends Fragment {
WebView wv;
private String NEWS = "mywebsite goes here";
#Override
public void onSaveInstanceState(Bundle outState) {
wv.saveState(outState);
}
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Toast.makeText(getContext(), "landscape", Toast.LENGTH_SHORT).show();
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
Toast.makeText(getContext(), "portrait", Toast.LENGTH_SHORT).show();
}
}
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ProgressBar Pbar;
View view = inflater.inflate(R.layout.webviewfrag, null, false);
if (savedInstanceState == null) {
((WebView )view.findViewById(R.id.NewsFeedWbview)).restoreState(savedInstanceState);
wv = (WebView) view.findViewById(R.id.NewsFeedWbview);
wv.setScrollbarFadingEnabled(false);
Pbar = (ProgressBar) view.findViewById(R.id.pBwvf);
final TextView tv = (TextView) view.findViewById(R.id.tV69);
wv.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
if (progress < 100 && Pbar.getVisibility() == ProgressBar.GONE) {
Pbar.setVisibility(ProgressBar.VISIBLE);
tv.setVisibility(View.VISIBLE);
}
Pbar.setProgress(progress);
if (progress == 100) {
Pbar.setVisibility(ProgressBar.GONE);
tv.setVisibility(View.GONE);
}
}
});
wv.getSettings().setJavaScriptEnabled(true);
wv.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
wv.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
wv.getSettings().setLoadsImagesAutomatically(true);
wv.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
if (Build.VERSION.SDK_INT >= 19) {
// chromium, enable hardware acceleration
wv.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else {
// older android version, disable hardware acceleration
wv.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
wv.canGoBackOrForward(5);
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setUseWideViewPort(true);
wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
wv.setPadding(0, 0, 0, 0);
wv.loadUrl(NEWS);
}
return view;
}
}
Here my code:
Activity:
public class WebViewActivity extends Activity {
private WebView webView;
private EditText urlEditText;
private ProgressBar progress;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
urlEditText = (EditText) findViewById(R.id.urlField);
webView = (WebView) findViewById(R.id.webView);
webView.setWebChromeClient(new MyWebViewClient());
progress = (ProgressBar) findViewById(R.id.progressBar);
progress.setMax(100);
Button openUrl = (Button) findViewById(R.id.goButton);
openUrl.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View view) {
String url = urlEditText.getText().toString();
if (validateUrl(url)) {
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
WebViewActivity.this.progress.setProgress(0);
}
}
private boolean validateUrl(String url) {
return true;
}
});
}
private class MyWebViewClient extends WebChromeClient {
#Override
public void onProgressChanged(WebView view, int newProgress) {
WebViewActivity.this.setValue(newProgress);
super.onProgressChanged(view, newProgress);
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.web_view, menu);
return true;
}
public void setValue(int progress) {
this.progress.setProgress(progress);
}
}
Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".WebViewActivity" >
<LinearLayout
android:id="#+id/urlContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/urlField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:hint="Enter URL to open" />
<Button
android:id="#+id/goButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Open" />
</LinearLayout>
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/urlContainer" />
<WebView
android:id="#+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/progressBar" />
</RelativeLayout>
Use below code
wv.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
// do your stuff here
}
});
So i am trying to run the Quickblox sample chat and XMPP Sample Chat.
Im using Eclipse with the newest Android sdk/build.
After importing the sample, the way the Quickblox guide tells, i had a few errors in the in the code, but not much more than a few imports missing, but when im trying to run the app i get an error, the app installs correct but right after errors starts popping in on 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;
}
}}
My manifest file is:
<?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>
This is my error message:
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)
Open Properties->Java Build Path->Order and Export and check QB jar library. According to logs you haven't added it to the build.
1) First of all make sure that you have imported "quickblox-android-1.2.2.jar" which comes with QuickBlox SDK in folder named jar then just Right click on project -> Properties -> Got to Java Build Path -> Order and Export -> just check quickblox-android-1.2.2.jar(which is unchecked in list) -> click Ok.
2)Just Clean the project and run it.
Note:- If you do not clean the project after step 1 then project will crash so clean the project before running it.