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.
Related
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.
I'd like to start an activity every time the phone has an incoming call and, inside the activity, show some details about the number or accept / refuse the call.
The problem is that every time i receive a call the activity doesn't start.
Here is my code:
public class PhoneCallReceiver extends AriesMobileBroadcastReceiver {
#Override
public void onReceive(final Context context, Intent intent) {
super.onReceive(context, intent);
if(!preferences.getBoolean(Preferences.CALL_SHOW_CUSTOMER_INFOS, false))
return;
TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen(new PhoneStateListener() {
public void onCallStateChanged(int state, final String incomingNumber){
switch(state){
case TelephonyManager.CALL_STATE_IDLE:
Log.d(TAG, "IDLE");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d(TAG, "OFFHOOK");
break;
case TelephonyManager.CALL_STATE_RINGING:
Log.d(TAG, "RINGING: " + incomingNumber);
final Intent intent = new Intent(context, PhoneCallActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(PhoneCallActivity.EXTRA_PHONE_NUMBER, incomingNumber);
new Thread() {
public void run() {
long now = AriesUtils.currentTimeStamp();
try {
Thread.sleep(500);
} catch(InterruptedException e) {}
now = AriesUtils.currentTimeStamp() - now;
Log.e(TAG, "ELAPSED TIME: " + now);
context.startActivity(intent);
}
}.start();
break;
}
}
}, PhoneStateListener.LISTEN_CALL_STATE);
}
the activity (which, actualy, does nothing ):
public class PhoneCallActivity extends AriesMobileActivity {
public static final String EXTRA_PHONE_NUMBER = "phone_number";
private TextView tvPhoneCallContact;
private TextView tvPhoneCallNumber;
private TextView tvPhoneCallSystem;
private ImageView imgPhoneCallStatus;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.e(TAG, "PHONE CALL ACTIVITY STARTED");
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
window.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
window.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
setContentView(R.layout.layout_phone_call);
Intent intent = getIntent();
if(!intent.hasExtra(EXTRA_PHONE_NUMBER)) {
finish();
return;
}
String phoneNumber = intent.getStringExtra(EXTRA_PHONE_NUMBER);
phoneNumber = phoneNumber.replace("+39", "").replace(" ", "");
CustomerContact[] contacts = new CustomerContact.Provider(context).findByPhoneNumber(phoneNumber);
if(contacts.length <= 0) {
finish();
return;
}
}
and the layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test1"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test2"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Answer" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Refuse" />
</LinearLayout>
So my requests are:
1- how do i start the activity when the phone rings?
2- how do i manage the respond/refuse button?
3- if this solution is impossible/not good/stupid is there any other way to show informations when a call is received? (for example some kind of notification)
thanks in advance
manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ngs.ariesmobile"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:name=".AriesMobileApplication"
android:allowBackup="true"
android:icon="#drawable/app_logo"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Light.NoActionBar" >
<receiver android:name=".receivers.PhoneCallReceiver" >
<intent-filter >
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
<activity
android:name=".view.LoginActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".view.HomeActivity"
android:label="#string/app_name" />
<activity
android:name=".view.SignatureCaptureActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" />
<activity
android:name=".view.SetupHomeActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name" />
<activity
android:name=".view.SetupApiActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name" />
<activity
android:name=".view.SetupLoginActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name" />
<activity
android:name=".view.SetupTechnicianActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name" />
<activity
android:name=".view.SettingsActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name" />
<activity
android:name=".view.SettingsPasswordActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name" />
<activity
android:name=".view.SettingsApiActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name" />
<activity
android:name=".view.SynchronizationActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name" />
<activity
android:name=".view.ReportCustomerActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" />
<activity
android:name=".view.ReportInternalActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" />
<activity
android:name=".view.ReportListActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name" />
<activity
android:name=".view.TicketListActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name" />
<activity
android:name=".view.PhoneCallActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent" />
<activity
android:name=".view.SystemActivity"
android:configChanges="orientation|keyboard|screenSize"
android:screenOrientation="landscape"
android:label="#string/app_name" />
<activity
android:name=".view.SystemListActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/app_name" />
<activity
android:name=".view.ReportSummaryActivity"
android:configChanges="orientation|keyboard|screenSize"
android:screenOrientation="portrait"
android:label="#string/app_name" />
<activity
android:name=".view.ManualsListActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/title_activity_manuals_list" >
</activity>
<activity
android:name=".view.SystemStoricalActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/title_activity_system_storical" >
</activity>
<activity
android:name=".view.SystemTechnicalPartActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/title_activity_system_technical_part" >
</activity>
<activity
android:name=".view.SystemConsActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/title_activity_system_cons" >
</activity>
<activity
android:name=".view.SystemNoteActivity"
android:configChanges="orientation|keyboard|screenSize"
android:label="#string/title_activity_system_note" >
</activity>
<activity
android:name=".view.SystemSupervisionActivity"
android:configChanges="orientation|screenSize"
android:label="#string/title_activity_system_supervision" >
</activity>
<activity
android:name=".view.CalendarActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="landscape"
android:label="#string/title_activity_calendar" >
</activity>
<activity
android:name=".view.ReportHoursActivity"
android:label="#string/title_activity_report_hours" >
</activity>
<!--- <activity
android:name="ngs.ariesmobile.view.ReportHoursActivity"
android:label="#string/title_activity_report_hours" >
</activity> -->
</application>
</manifest>
I have created xml layout file. And when I give it as content to my Activity the TITLE BAR IS NOT VISIBLE. How can I make it visible. I tried to use setTitle("Title");
protected void onCreate(Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
Bundle b = getIntent().getExtras();
int layoutId = b.getInt("layout");
Log.d("====>>>", " " + layoutId);
setContentView(layoutId);
setTitle("Title");
}
function in onCreate() method. I is not work. This is my xml file.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<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" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.universityapp.enrollee.FacultyInformationActivity"
android:scrollbars="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="#string/text_faculty_information_agro"
android:textSize="15dp"
android:textAlignment="center"
/>
</RelativeLayout>
</ScrollView>
I start activity via ListView:
profListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position){
case 0:
facultyInfoIntent = new Intent(getBaseContext(), FacultyInformationActivity.class);
Bundle b = new Bundle();
b.putInt("layout", facultyLayoutNames[position]);
facultyInfoIntent.putExtras(b);
startActivity(facultyInfoIntent);
}
Log.d("Selected faculty", facultiNames[position]);
}
});
This is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.universityapp.universityapp" >
<uses-permission android:name="android.permission.CALL_PHONE" />
<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.CALL_PHONE" />
<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" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity android:name="com.universityapp.common.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.universityapp.common.MenuActivity"
android:label="Главное меню" >
</activity>
<activity
android:name="com.universityapp.enrollee.ContacsActivity"
android:label="Наши контакты" >
</activity>
<activity
android:name="com.universityapp.enrollee.Map"
android:label="#string/title_activity_map" >
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name="com.universityapp.enrollee.MapsActivity"
android:label="#string/title_activity_maps" >
</activity>
<activity
android:name="com.universityapp.bachelor.PlatonusActivity"
android:label="#string/title_activity_platonus" >
</activity>
<activity
android:name="com.universityapp.database.DatabaseActivity"
android:label="#string/title_activity_database" >
</activity>
<activity
android:name="com.universityapp.enrollee.EnrUniversityInfo"
android:label="#string/title_activity_enr_university_info" >
</activity>
<activity
android:name="com.universityapp.enrollee.ProfessionsActivity"
android:label="#string/title_activity_professions" >
</activity>
<activity
android:name="com.universityapp.enrollee.FacultyInformationActivity"
android:label="#string/title_activity_faculty_information" >
</activity>
</application>
</manifest>
Change:
public class MainActivity extends Activity{
}
in your class file to:
public class MainActivity extends AppCompatActivity{
}
I found the answer! I have changed Activity to ActionBarActivity and it works!
To show the title bar you can use this in your onCreate:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
You can do it by doing this (as suggested by HafizWaleedHussain):
public void showTitle() {
try {
((View) findViewById(android.R.id.title).getParent())
.setVisibility(View.VISIBLE);
} catch (Exception e) {
}
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
If this didn't work then open your Android Manifest file and remove this line if it exist:
android:theme="#android:style/Theme.NoTitleBar"
Got o styles.xml and make a new style
<style name="CustomWindowTitleBackground">
<item name="android:background">#323331</item>
<item name="android:windowNoTitle">false</item>
</style>
and call it from Manifest (You can also add other features inside item tags)
<activity
android:name=".st.activity.MyGoogleMap"
android:theme="#style/CustomWindowTitleBackground">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I removed the statement android:theme="#style/AppTheme" in the application tag and the bar started appearing
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
**android:theme="#style/AppTheme"**>
package com.netvariant.zain.activity;
public class StoreMapActivity extends SherlockFragmentActivity {
private GoogleMap googleMap;
String longitude="0";
String latitude="0";
String title="";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
Bundle extras = getIntent().getExtras();
longitude = extras.getString("longitude");
latitude = extras.getString("lattitude");
title= extras.getString("name");
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
private void initilizeMap() {
if (googleMap == null) {
double savedLat = Double.parseDouble(latitude);
double savedLng =Double.parseDouble(longitude);
LatLng cameraLatLng = new LatLng(savedLat, savedLng);
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(
R.id.map)).getMap();
googleMap.addMarker(new MarkerOptions()
.position(new LatLng( Float.parseFloat(latitude), Float.parseFloat(longitude))).title("Marker")
.title(title));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(cameraLatLng, 17));
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
protected void onResume() {
super.onResume();
initilizeMap();
}
}
This is my map class, on samsung s4 4.2.2 it crashes. I use google play services froyo for it.
The layout is simple, its a fragment. Unfortunately, I dont have s4 myself to detect whats happening. Its being reported by someone trying it on s4 that its crashing. Any helps would be thankful.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
my manifest file and hope it helps.....
<uses-permission android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_USER_DICTIONARY" />
<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_MOCK_LOCATION" />
<application
android:name="com.netvariant.zain.android.ZainApp"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.netvariant.zain.activity.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>
<activity
android:name="com.netvariant.zain.activity.RegionalStoresActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.RegionalStoresMeActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.UsageActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.StoresActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.PackagePlanActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.CategoriesActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.LoadingActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.LoginActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.LoginAuthenticationActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.SlidingMenuActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.CategoriesNewsActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.ArticlesActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.ArticlesNewsActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.StoreMapActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.PostPaidMenuVoiceActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.PrePaidMenuVoiceActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.PrePaidMenuDataActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.PostPaidMenuDataActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.BillsActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.ExtrasActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.BillsAmountActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.netvariant.zain.activity.CallDetailsInnerActivity"
android:screenOrientation="portrait" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyD6geBmLw7N6gkDy1zCg7Y4yMtf_QnAOMs" />
</application>
Add the following,
< meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" >
< /meta-data>
in your manifest file immediately below the first meta-data tag(where you have placed your google api key)
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>