NoClassDefFoundError for Pojo class in Splash Screen - android

AndroidManifest.java
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bidnextjob.bidnextjob">
<!-- Lat lon fetching permission by GPSTracker class start and also use for google map -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.bidnextjob.bidnextjob.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Allows access to the flashlight -->
<permission
android:name="android.permission.FLASHLIGHT"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="normal" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/MyTheme">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".RegisterActivity" />
<activity
android:name=".HomeActivity"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity android:name=".FilterActivity" />
<activity android:name=".JobDetailsActivity" />
<activity android:name=".EditProfileActivity"
android:windowSoftInputMode="stateAlwaysHidden"/>
<activity
android:name=".ChatActivity"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity android:name=".AboutUsActivity" />
<activity android:name=".HelpActivity" />
<activity android:name=".ReviewActivity" />
<activity
android:name=".CommentActivity"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity android:name=".ForgetPasswordActivity" />
<activity
android:name=".PlaceBidActivity"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity
android:name=".EditBidActivity"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity android:name=".JobDetails1Activity" />
<activity android:name=".NotificationsActivity" />
<activity android:name=".ChooseCategoryActivity" />
<activity android:name=".BidDetailsActivity" />
<activity android:name=".EditAddressActivity" />
<activity android:name=".UpdateProfileActivity" />
<activity android:name=".GiveRatingActivity" />
<activity android:name=".ArchiveActivity"/>
<activity android:name=".AutoCompleteAddress"/>
<activity
android:name=".SocialLoginActivity"
android:label=".SocialLoginActivity" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="<some api key>" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<service android:name="utilities.gcm.GcmIntentService" />
<receiver
android:name="utilities.gcm.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.bidnextjob.bidnextjob" />
</intent-filter>
</receiver>
</application>
</manifest>
I'm accessing a Pojo class having static method for returning value. When I access this static method in my Splash Screen class(Launcher page), I get a NoClassDefFoundError for that Pojo class. How to avoid this exception without making the method non-static?
LogCat
FATAL EXCEPTION: main
Process: com.bidnextjob.bidnextjob, PID: 30515
java.lang.NoClassDefFoundError: shared_pref.SharedStorage
at com.bidnextjob.bidnextjob.SplashActivity.onCreate(SplashActivity.java:21)
at android.app.Activity.performCreate(Activity.java:5280)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2322)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5388)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:655)
at dalvik.system.NativeStart.main(Native Method)
Pojo class
package shared_pref;
public class SharedStorage {
static SharedPreferences preference;
private static String prefData="ExampleStructApp";
public static String UserId= "UserId";
public static String UserType= "UserType";
public static void setValue(Context context,String key,String data){
preference = context.getSharedPreferences(prefData, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preference.edit();
editor.putString(key,data);
editor.commit();
}
public static String getValue(Context context,String key){
preference = context.getSharedPreferences(prefData, Context.MODE_PRIVATE);
String id = preference.getString(key,"");
return id;
}
public static void resetValue(Context context){
preference = context.getSharedPreferences(prefData, Context.MODE_PRIVATE);
preference.edit().clear().commit();
}
}
Splash Screen class
public class SplashActivity extends AppCompatActivity {
private String user_id = "";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
// Here I get NoClassDefFoundError
user_id = SharedStorage.getValue(getApplicationContext(),"UserId");
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
if(user_id != null && !user_id.isEmpty()){
startActivity(new Intent(SplashActivity.this, HomeActivity.class));
finish();
}else{
startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();
}
}
}, 3000);
}
}

This is caused when there is a class file that your code depends on and it is present at compile time but not found at runtime. Look for differences in your build time and runtime classpaths.

Related

How to save data from EditTexts in RecyclerView during screen rotation

I read that EditText doesn't work well with RecyclerView, but I saw an application where it works well (avito). Now I am trying to understand how it was realized there.
I have a fragment with RecyclerView, in recycler view I have EditTexts only in header holder (only one item with EditTexts). In this header I have about five similar EditTexts and TextViews (city,title,description,price etc.) So as not to duplicate the code for all views, I made a custom view class where I located these views, and this class I show below.
public class CustomEditTextView extends LinearLayout implements TextWatcher {
private LayoutInflater inflater;
private TextView textView;
private final EditText editText;
private TextView tvWarning;
private View view;
private String hint;
private String text ;
private String title;
private String warning;
private boolean isNumber = false;
private SpinnerCitySetupListener spinnerCitySetupListener;
public CustomEditTextView(Context context, AttributeSet attrs) {
super(context, attrs);
inflater = LayoutInflater.from(context);
view = inflater.inflate(R.layout.custom_edittext, this, true);
textView = (TextView) view.findViewById(R.id.mycustom_tvTitle);
editText = (EditText) view.findViewById(R.id.mycustom_etTitle);
tvWarning = (TextView) view.findViewById(R.id.mycustom_tvWarning);
textView.setVisibility(GONE);
tvWarning.setVisibility(GONE);
}
public void setCustomVisibility(View view,boolean isVisible){
view.setVisibility(isVisible?VISIBLE:GONE);
}
public void tuningView() {
editText.addTextChangedListener(this);
if(isNumber)editText.setInputType(InputType.TYPE_CLASS_NUMBER);
}
public void setTitle(String title){
textView.setText(title);
this.title = title;
}
public void setHint(String hint){
editText.setHint(hint);
this.hint = hint;
}
public void setWarning(String warning){
tvWarning.setText(warning);
this.warning = warning;
}
public void setText(String text) {
editText.setText(text);
}
public String getText(){
Log.i("CUSTOM VIEW","GET TEXT FROM VIEW: "+ text);
return text;
}
public TextView getTvWarning(){
return tvWarning;
}
public void setInputType(boolean isNumber){
this.isNumber = isNumber;
}
public void setSpinnerCityListener(SpinnerCitySetupListener listener){
spinnerCitySetupListener = listener;
}
//region TextChangedListener
#Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
text = charSequence.toString();
}
#Override
public void afterTextChanged(Editable editable) {
if (editable.toString().length()!= 0) {
setCustomVisibility(textView,true);
text = editable.toString();
if(spinnerCitySetupListener!= null) spinnerCitySetupListener.spinnerActivation(false);}
else {setCustomVisibility(textView,false);
if(spinnerCitySetupListener!= null) spinnerCitySetupListener.spinnerActivation(true);}
}
//endregion
}
my manifest:`
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<!-- <uses-permission android:name="android.permission.SEND_SMS"/>-->
<permission
android:name="com.android.qrz.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.android.qrz.gcm.permission.C2D_MESSAGE" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<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_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="#drawable/qrz_icon"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<!--android:name=".QRZApp"-->
<meta-data
android:name="AA_DB_NAME"
android:value="QRZ.db" />
<meta-data
android:name="AA_DB_VERSION"
android:value="1" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyBlOgCglvJdnPS476oiF4MRAo3pV3nQ8w8"/>
<receiver
android:name=".receiver.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.android.qrz.receiver" />
</intent-filter>
</receiver>
<receiver
android:name=".receiver.InternetCheckReceiver"
android:label="NetworkConnection" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<service
android:name=".services.GCMIntentService"
android:process=":remote" />
<activity
android:name=".activity.SplashScreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--<activity-->
<!--android:name=".activity.main_menu.MainMenu"-->
<!--android:label="#string/title_activity_menu" >-->
<!--</activity>-->
<activity
android:name=".activity.main_menu.NewMainMenu"
android:label="#string/title_activity_menu" >
</activity>
<activity
android:name=".activity.LoginActivity"
android:label="#string/title_activity_login" >
</activity>
<!--<activity-->
<!--android:name=".activity.Registration"-->
<!--android:label="#string/title_activity_registration" >-->
<!--</activity>-->
<activity
android:name=".activity.registration.NewRegistration"
android:label="#string/title_activity_registration" >
</activity>
<activity
android:name=".activity.News"
android:label="#string/title_activity_news" >
</activity>
<activity
android:name=".activity.news.DetailNewsActivity"
android:label="#string/title_activity_news" >
</activity>
<!--<activity-->
<!--android:name=".activity.Callbook"-->
<!--android:label="#string/title_activity_callbook" >-->
<!--</activity>-->
<activity
android:name=".activity.NewCallbook"
android:label="Callbook" >
</activity>
<activity
android:name=".activity.PhotoGallery"
android:label="#string/title_activity_photo_gallery" >
</activity>
<!--<activity
android:name=".activity.DiplomsActivity"
android:label="#string/title_activity_diploms" >
</activity>-->
<activity
android:name=".activity.new_diploms.ui.MainDiplomActivity"
android:label="#string/title_activity_new_diploms" >
</activity>
<activity
android:name=".activity.new_diploms.ui.detail_diplom.DiplomDetailActivity"
android:label="#string/title_activity_new_detail_diploms" >
</activity>
<activity
android:name=".activity.new_diploms.ui.searching.SearchingActivity"
android:label="#string/title_activity_searching_diploms" >
</activity>
<activity
android:name=".activity.BirthdaysActivity"
android:label="#string/title_activity_birthdays" >
</activity>
<activity
android:name=".activity.competitions.CompetitionsActivity"
android:label="#string/title_activity_competitions" >
</activity>
<activity
android:name=".activity.DXActivity"
android:label="#string/title_activity_DX" >
</activity>
<activity
android:name=".activity.DXDetailActivity"
android:label="#string/title_activity_DX_detail" >
</activity>
<activity
android:name=".activity.base_of_frequency.BaseFrequencyActivity"
android:label="#string/title_activity_frequency" >
</activity>
<activity
android:name=".activity.qsl.QslActivity"
android:label="#string/title_activity_qsl" >
</activity>
<activity
android:name=".activity.qsl.QSLSearching"
android:label="#string/title_activity_qsl_searching" >
</activity>
<activity
android:name=".activity.declarations.BillboardActivity"
android:label="#string/title_activity_billboard" >
</activity>
<activity
android:name=".activity.declarations.SearchingFilterActivity"
android:label="#string/title_activity_filters_for_search"
>
</activity>
<activity
android:name=".activity.declarations.NewSearchingDeclarationActivity"
android:label="#string/title_activity_searching_declaration" >
</activity>
<activity
android:name=".activity.declarations.ListDeclarationsActivity"
android:label="#string/title_activity_list_declarations" >
</activity>
<activity
android:name=".activity.declarations.DeclarationDetailActivity"
android:label="#string/title_activity_declaration_detail" >
</activity>
<activity
android:name=".activity.personal_activity.PersonalActivity"
android:label="#string/title_activity_personal" >
<intent-filter>
<action android:name="android.intent.action.PICK"></action>
</intent-filter>
</activity>
<activity
android:name=".activity.personal_activity.create_declaration.CreateDeclarationActivity"
android:label="#string/title_activity_create_declaration" >
</activity>
<activity
android:name=".activity.personal_activity.create_qsl_manager.CreateQSLManagerActivity"
android:label="#string/title_activity_create_qsl" >
</activity>
<activity
android:name=".activity.personal_activity.create_dx_reporter.CreateDXReporterActivity"
android:label="#string/title_activity_create_dx_reporter" >
</activity>
<activity
android:name=".activity.personal_activity.create_frequency.CreateFrequencyActivity"
android:label="#string/title_activity_create_frequency" >
</activity>
<activity
android:name=".activity.personal_activity.settings.PersonalSettingsActivity"
android:label="#string/title_activity_settings" >
</activity>
<activity
android:name=".activity.ForumActivity"
android:label="#string/title_activity_forum" >
</activity>
<activity
android:name=".activity.AboutAppActivity"
android:label="#string/title_activity_about_app" >
</activity>
<service
android:name=".rest_service.rest.RestService"
android:enabled="true"
android:exported="true" >
</service><!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
`
My problem is variable "text" in afterTextChanged or in onTextChanged "text" is not empty, in this part of code all works well, but when I want to get this text from my headerHolder I calling customView.getText() for sending this data in fragment for OnSavedInstance and this variable "text" become null, but EditText contains text all this time, why does this happen?

Background service using alarm manager

I have followed below example code for implementing Periodic background service. Periodic task executes correctly If app on foreground on 1st time. If, I close application then Background service is not working.
https://github.com/codepath/android_guides/wiki/Starting-Background-Services#using-with-alarmmanager-for-periodic-tasks
1) BroadcastReceiver service for Bootcomplete
public class BootBroadcastReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
// Launch the specified service when this message is received
Intent startServiceIntent = new Intent(context, MyTestService.class);
context.startService(startServiceIntent);
}
}
2) BroadcastReceiver to start service
public class MyAlarmReceiver extends BroadcastReceiver {
public static final int REQUEST_CODE = 12345;
// Triggered by the Alarm periodically (starts the service to run task)
#Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, MyTestService.class);
i.putExtra("foo", "bar");
context.startService(i);
Toast.makeText(context, "Welcome --------1", Toast.LENGTH_LONG).show();
}
}
3) IntenetService class: To execute my background task
public class MyTestService extends IntentService {
// Must create a default constructor
public MyTestService() {
// Used to name the worker thread, important only for debugging.
super("test-service");
}
#Override
public void onCreate() {
super.onCreate(); // if you override onCreate(), make sure to call super().
}
#Override
protected void onHandleIntent(Intent intent) {
}
}
4) Service is started from activity as
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scheduleAlarm();
}
// Setup a recurring alarm every half hour
public void scheduleAlarm() {
// Construct an intent that will execute the AlarmReceiver
Intent intent = new Intent(getApplicationContext(), MyAlarmReceiver.class);
// Create a PendingIntent to be triggered when the alarm goes off
final PendingIntent pIntent = PendingIntent.getBroadcast(this, MyAlarmReceiver.REQUEST_CODE,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
// Setup periodic alarm every 5 seconds
long firstMillis = System.currentTimeMillis(); // alarm is set right away
AlarmManager alarm = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
// First parameter is the type: ELAPSED_REALTIME, ELAPSED_REALTIME_WAKEUP, RTC_WAKEUP
// Interval can be INTERVAL_FIFTEEN_MINUTES, INTERVAL_HALF_HOUR, INTERVAL_HOUR, INTERVAL_DAY
alarm.setRepeating(AlarmManager.RTC_WAKEUP, firstMillis,
30000, pIntent);
}
}
5) Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="test.org.help">
<permission
android:name="test.org.help.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="au.com.KPS.companion.ACCESS_DATA" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="test.org.help.permission.UA_DATA" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- This app has permission to register with GCM and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="test.org.help.permission.C2D_MESSAGE" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.flash"
android:required="false" />
<uses-feature android:name="android.hardware.screen.landscape" />
<application
android:name="test.org.help.KPSApp"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:logo="#drawable/ic_actionbar_logo"
android:theme="#style/AppTheme"
tools:replace="android:icon, android:logo">
<!-- Activities -->
<activity
android:name="test.org.help.ui.activity.SplashActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.activity.JanRainLoginActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activity.LinkListActivity"
android:screenOrientation="portrait" />
<activity
android:name="test.org.help.ui.activity.KPSFragmentActivity"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"></activity>
<activity
android:name="test.org.help.ui.activity.NotificationDialogActivity"
android:excludeFromRecents="true"
android:label=""
android:launchMode="singleInstance"
android:noHistory="true"
android:screenOrientation="portrait"
android:taskAffinity=""
android:theme="#style/AppTheme.Dialog.Notification"></activity>
<receiver
android:name="test.org.help.receivers.NotificationReceiver"
tools:ignore="ExportedReceiver">
<intent-filter>
<action android:name="test.org.help.util.ACTION_SHOW_AGENDA" />
<action android:name="test.org.help.util.ACTION_SNOOZE" />
<action android:name="test.org.help.util.ACTION_DISMISS" />
<action android:name="test.org.help.util.ACTION_SHOW_DIALOG" />
<data android:scheme="KPS" />
<data android:mimeType="text/plain" />
<data android:pathPattern="au\.org\.KPS\.util/.*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.Light.NoTitleBar"
tools:replace="android:theme,android:screenOrientation"></activity>
<activity
android:name="test.org.help.ui.activity.AppTutorialActivity"
android:screenOrientation="portrait"
android:theme="#style/SplashTheme"></activity>
<activity
android:name="test.org.help.ui.activity.TermsAndConditionsActivity"
android:label="#string/title_terms_and_conditions"
android:screenOrientation="portrait"></activity>
<activity
android:name="test.org.help.ui.activity.WarningActivity"
android:label="#string/title_Warning"
android:screenOrientation="portrait"></activity>
<activity
android:name="test.org.help.ui.activity.DifferentUserWarningActivity"
android:label="#string/title_Warning"
android:screenOrientation="portrait"></activity>
<activity
android:name="test.org.help.ui.activity.AppWhatsNewActivity"
android:label="#string/title_Warning"
android:screenOrientation="portrait"></activity>
<activity
android:name=".ui.activity.UserUpgradeActivity"
android:label="#string/title_upgrade"
android:screenOrientation="portrait"></activity>
<activity
android:name="eu.janmuller.android.simplecropimage.CropImage"
android:label=""
android:screenOrientation="portrait"></activity>
<!-- Facebook -->
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<!-- Services -->
<receiver android:name="com.mobileapptracker.Tracker">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="test.org.help.service.DBUpdateService"
android:exported="false"
android:label="#string/app_name">
<intent-filter>
<action android:name="test.org.help.service.DBUpdateService"></action>
</intent-filter>
</service>
<receiver android:name="test.org.help.receivers.TimeChangeReceiver">
<intent-filter>
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
</intent-filter>
</receiver>
<activity
android:name="com.janrain.android.engage.ui.JRFragmentHostActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name="com.janrain.android.engage.ui.JRFragmentHostActivity$Fullscreen"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden" />
<!--Hockey app crash report-->
<meta-data
android:name="net.hockeyapp.android.appIdentifier"
android:value="#string/hockey_app_id" />
<receiver android:name="test.org.help.syncmanager.Network.NetworkAvailability">
<intent-filter>
<action android:name=".android.action.broadcast" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
</intent-filter>
</receiver>
<activity
android:name=".db.AndroidDatabaseManager"
android:theme="#style/Theme.AppCompat.Light" /><!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<service
android:name=".syncmanager.auto.MyTestService"
android:exported="false" />
<receiver
android:name=".syncmanager.auto.MyAlarmReceiver"
android:process=":remote"></receiver>
<receiver android:name=".syncmanager.auto.BootBroadcastReceiver">
</receiver>
</application>
</manifest>
If, implement above as sample project as separate then, background service is executing fine always. But If try to integrate with my existing code then not working...
Edited: Found Solution
It got resolved by adding full path android:name service in AndroidManifest.xml
<service
android:name="test.org.help.syncmanager.auto.MyTestService"
android:exported="false" />

ImageButtons not working - Android Studio

I have this WelcomeActivity where I programmed 4 ImageButtons to launch another activities.
This is my code:
public class WelcomeScreen extends Activity {
ImageButton completeprofile;
ImageButton gotoportfolio;
ImageButton findfriends;
ImageButton readnews;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome_activity);
completeprofile = (ImageButton) findViewById(R.id.completeprofile);
gotoportfolio = (ImageButton) findViewById(R.id.gotoportfolio);
findfriends = (ImageButton) findViewById(R.id.findfriends);
readnews = (ImageButton) findViewById(R.id.readnews);
completeprofile.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent i = new Intent(WelcomeScreen.this, LoginMember.class);
startActivity(i);
}
});
gotoportfolio.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent i = new Intent(WelcomeScreen.this, MainActivity.class);
startActivity(i);
}
});
findfriends.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent i = new Intent(WelcomeScreen.this, MainActivity.class);
startActivity(i);
}
});
readnews.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent i = new Intent(WelcomeScreen.this, RegisterMember.class);
startActivity(i);
}
});
}}
Problem is, they actually behave like buttons when I click them, but no activity is launched, this is the layout declaration:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="70dp"
android:layout_marginLeft="105dp">
<ImageButton
android:layout_width="55dp"
android:layout_height="55dp"
android:id="#+id/completeprofile"
android:src="#drawable/completeprofile"
android:layout_marginLeft="75dp"
android:contentDescription="completeprofile" />
<ImageButton
android:layout_width="55dp"
android:layout_height="55dp"
android:id="#+id/gotoportfolio"
android:src="#drawable/gotoportfolio"
android:layout_marginLeft="65dp" />
<ImageButton
android:layout_width="55dp"
android:layout_height="55dp"
android:id="#+id/findfriends"
android:src="#drawable/findfriends"
android:layout_marginLeft="65dp" />
<ImageButton
android:layout_width="55dp"
android:layout_height="55dp"
android:id="#+id/readnews"
android:src="#drawable/readnews"
android:layout_marginLeft="65dp" />
</LinearLayout>
Why is this happening? Maybe the intent launch has some issue?
Any ideas?
thanks in advance!
EDIT
Here's the manifest:
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="21"
tools:overrideLibrary="android.support.multidex" />
<supports-screens
android:largeScreens="true"
android:normalScreens="false"
android:requiresSmallestWidthDp="600"
android:smallScreens="false"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<!-- <uses-sdk /> -->
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/logo"
android:label="Shairlook"
android:theme="#style/AppTheme" >
<activity
android:name="com.kkoci.shairlook.SplashScreen"
android:configChanges="orientation"
android:label="Shairlook"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.kkoci.shairlook.MemberActivity"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.kkoci.shairlook.RegisterMember"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.kkoci.shairlook.LoginMember"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.kkoci.shairlook.WelcomeScreen"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.kkoci.shairlook.YoutubeVid"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.kkoci.shairlook.ProfileMember"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.kkoci.shairlook.PortfolioMember"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.kkoci.shairlook.ForgotPassActivity"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.kkoci.shairlook.MainActivity"
android:configChanges="orientation"
android:label="Shairlook"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.kkoci.shairlook.WebActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo" >
</activity>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
</application>
#override won't cause problem. It's quite weird if activities are added in manifest and present in same pkg.
can you please add debug Log in onClick(), this will narrow down the problem whether problem is really with callback or not.
try android:clickable="true"/android:focusable="true"/ android:focusableInTouchMode="true" as additional attributes for ImageButton
Hope this helps!
You should remove the '#Override' from above each onClick method, they are not needed and this may be causing you an issue.

Unable to retrieve ads form airpush

Got myself newly registered on AirPush. I integrated bundle SDK with my App. When I tested it for the first time, I got a couple of impressions. It also shows 2 impressions on dashboard.
Now I am unable to fetch the impressions. Did contact the developer team but to no avail.
My code of MainActivity goes like this :
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// MMSDK.initialize(this);
// setup a new adView and initialize an adRequest to it.
setupAirPushAdView();
}
#Override
public void onResume() {
super.onResume();
if ((getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK)
== Configuration.SCREENLAYOUT_SIZE_SMALL) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
try {
if (!appStarted) {
setContentView(R.layout.main);
appStarted = true;
}
} catch (Exception e) {
Toast.makeText(this, e.getMessage() + "\n" + e.getClass().toString() + "\n" + e.getLocalizedMessage() + "\n", Toast.LENGTH_LONG).show();
}
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
perform();
}
}, 2000);
}
private void perform() {
setContentView(R.layout.app_home);
if (!appStarted) {
// attachAdView();
attachAirPushAdView();
appStarted = true;
}
...
Other Methods :
private void setupAirPushAdView() {
ma = new MA(this, null, false);
airPushAdView = new AdView(this, AdView.BANNER_TYPE_IN_APP_AD, AdView.PLACEMENT_TYPE_INTERSTITIAL, false, false,
AdView.ANIMATION_TYPE_LEFT_TO_RIGHT);
}
private void attachAirPushAdView() {
LinearLayout outerAdLayout = (LinearLayout) findViewById(R.id.externalAdId);
outerAdLayout.addView(airPushAdView);
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-sdk android:minSdkVersion="9"/>
<!-- android:theme="#android:style/Theme.DeviceDefault.Light" -->
<!-- android:theme="#android:style/Theme.Light.NoTitleBar.Fullscreen" -->
<application android:theme="#style/AppTheme" android:label="#string/app_name" android:icon="#drawable/ic_launcher">
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<activity android:name="MainActivity"
android:label="#string/app_name"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="nosensor"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="differential_activity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="nosensor"
>
</activity>
<activity android:name="integral_activity"
android:screenOrientation="portrait"
>
</activity>
<activity android:name="equation_activity"
android:screenOrientation="portrait"
>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<!-- android:configChanges="keyboardHidden|orientation"
android:screenOrientation="nosensor" -->
<!-- for all activities -->
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="com.gyesa.keanp176500.APPID" android:value="206488" />
<meta-data android:name="com.gyesa.keanp176500.APIKEY" android:value="android*1392147786176500813"/>
<activity android:exported="false" android:name="com.gyesa.keanp176500.AdActivity"
android:configChanges="orientation|screenSize"
android:theme="#android:style/Theme.Translucent" />
<activity android:name="com.gyesa.keanp176500.BrowserActivity"
android:configChanges="orientation|screenSize" />
<activity android:name="com.gyesa.keanp176500.VActivity"
android:configChanges="orientation|screenSize" android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<service android:name="com.gyesa.keanp176500.LService" android:exported="false"></service>
<receiver android:name="com.gyesa.keanp176500.BootReceiver" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
<uses-feature android:name="android.hardware.microphone" android:required="false" />
</manifest>

UnityPlayerActivity not getting onCreate() log

I am trying to extend UnityPlayerActivity with the help of docs.unity3d. I have a simple jar file with MainActivity class and also included the file classes.jar to the libs folder. My class file has following code.
package com.example.testactivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import com.unity3d.player.UnityPlayerActivity;
public class MainActivity extends UnityPlayerActivity
{
#Override
public void onCreate(Bundle savedInstanceState) {
Log.i("Hiren","==============ON CREATE CALLED==============");
super.onCreate(savedInstanceState);
}
public static void callMe()
{
Log.i("Hiren","==============Function CALLED==============");
}
}
I can call the static function callMe () through my c# script but my onCreate() is not called at the start of the activity. My C# script is
private static FBShare _instance;
public static FBShare Instance
{
get
{
if(_instance == null)
_instance = new FBShare();
return _instance;
}
}
private AndroidJavaClass cls_Fb = new AndroidJavaClass("com.example.testactivity.MainActivity");
public void CallMe()
{
using(AndroidJavaClass cls_UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
using(AndroidJavaObject obj_Activity = cls_UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
{
cls_Fb.CallStatic("callMe");
}
}
When I call "CallMe" method, I get log of being called. but I didnt get any log from onCreate().
AndroidMenifest.xml file contains
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testactivity.MainActivity"
android:installLocation="preferExternal"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>
<application
android:label="#string/app_name"
android:debuggable="true">
<activity android:name="com.unity3d.player.UnityPlayerProxyActivity"
android:label="#string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.unity3d.player.UnityPlayerActivity"
android:label="#string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
</activity>
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
android:label="#string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
</activity>
<activity android:name="com.unity3d.player.VideoPlayer"
android:label="#string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
</activity>
<activity android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboardHidden|orientation" >
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_INTERNET" />
</application>
</manifest>
as nicolas said, check the manifest
make sure this section is correct
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Categories

Resources