I created an app using android studio. Uploaded to play store. Its working fine in all devices except android version 5.1 and lower version devices. The app is not even opening in those devices.
I have tried my best to solve this problem but I failed.
.
So, please tell me guys how to solve it??
.
In stack trace it is showing :
.
Caused by : android.view.inflateException
.
At packageName.splash.oncreate (Splash.java:23)
.
Here Splash.java is my splash screen activity...
Here is my Splash.java code :
public class Splash extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setupWindowAnimations();
TextView textView = findViewById(R.id.textviewmain);
TextView textView1 = findViewById(R.id.textviewmain2);
ImageView logo = findViewById(R.id.logo_s);
Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fadein);
logo.startAnimation(animation1);
textView.startAnimation(animation1);
textView1.startAnimation(animation1);
Thread timer = new Thread(){
#Override
public void run(){
try {
sleep(3000);
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
super.run();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
timer.start();
}
private void setupWindowAnimations() {
Fade fade = new Fade();
fade.setDuration(3000);
getWindow().setExitTransition(fade);
}
}
and activity_splash.xml code is :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#092865"
tools:context=".Splash"
android:theme="#style/AppTheme.NoActionBar">
<ImageView
android:id="#+id/splashbg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-315dp"
android:src="#drawable/splashbg2"
/>
<RelativeLayout
android:id="#+id/slidesplash"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="100dp"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:background="#null"
android:gravity="center_horizontal">
<ImageView
android:id="#+id/logo_s"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerVertical="true"
android:contentDescription="#string/daily_highlights_dose"
android:src="#drawable/icon24"
android:transitionName="logo" />
<TextView
android:id="#+id/textviewmain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"
android:layout_toEndOf="#id/logo_s"
android:text="#string/sports"
android:textColor="#ffffff"
android:textSize="25sp" />
<TextView
android:id="#+id/textviewmain2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/textviewmain"
android:text="Highlights"
android:textColor="#1FD883"
android:textSize="27sp" />
</RelativeLayout>
<!-- #f93959 -->
</RelativeLayout>
I think this problem is ocuuring just because of size of images,
You should check your image size which are put in splash Activity
or replace those images by others and then check it
Related
On my Android app (react-native but it doesn't matter) I have a splash screen. I created res/drawable and added a image called "emblem.png". I then center that with gravity of center as seen in my xml here:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item name="android:windowBackground">#drawable/background</item>
<item>
<bitmap android:gravity="center" android:src="#drawable/emblem"/>
</item>
</layer-list>
However this centering does not take into consideration the "top status bar" height nor the "width of 'system nav bar' when landscape"/"height of 'system nav bar' when in portrait". Is there a way to do this?
Thanks
THIS IS NOT AN ANSWER, I'M JUST SHARING SOME CODELayout file - activity_splash.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:id=#+id/activity_splash"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
tools:context="com.splash.splash.Splash">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:id="#+id/iV"
android:gravity="center"
android:src="#drawable/applogo"/>
<TextView
android:layout_width="wrap_content"
android:gravity="center"
android:layout_height="wrap_content"
android:text="My welcome screen"
android:textsize="25sp"
android:textStyle="bold"
android:textcolor="#color/white"
android:layout_marginTop="10dp"
android:id="#+id/tV" />
</LinearLayout>
</RelativeLayout>
MainActivity.java
public class Splash extends AppCompatActivity{
private TextView tv;
private ImageView iv;
#Override
protected void onCreate(Bundle savedInstanceState){
super.OnCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
tv= findViewById(R.id.tV);
iv= findViewById(R.id.iV);
final intent i = new intent(this,MainActivity.class);
Thread timer = new thread(){
public void run(){
try{
sleep(5000);
}catch(InterruptedException e){
e.printStackTrace();
}
finally{
startActivity(i);
finish();
}
}
};
timer.start();
}
}
This is how I set a splash screen in android. Hope this helps you.
I have a about us page in android and there is a google play store image. On click of that image i want to open google play store
Can any1 help me about how to do this thing? XML file and java class attached below. I am a newbie in android so please tell about all the changes to be made in all the files. Thanks
about us xml file
<LinearLayout
android:id="#+id/share_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="#dimen/dividerMargin">
<TextView
android:id="#+id/dummyText"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
/>
<ImageView
android:id="#+id/playstoreImg"
android:layout_width="110dp"
android:layout_height="40dp"
android:src="#drawable/google_play" />
<ImageView
android:id="#+id/appstoreImg"
android:layout_width="110dp"
android:layout_height="40dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:src="#drawable/ios_app_store" />
</LinearLayout>
About us java file
public class AboutUs extends BaseActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about_us);
setBackBtnVisibility(true);
setTitle(getString(R.string.by_mobi));
ButterKnife.bind(this);
}
}
in your XML Layout:
<ImageView
android:id="#+id/appstoreImg"
android:layout_width="110dp"
android:layout_height="40dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:src="#drawable/ios_app_store"
android:onClick="openGooglePlay" />
In your activity / java file add this method:
public void openGooglePlay(View v) {
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.android.vending");
ComponentName comp = new ComponentName("com.android.vending", "com.google.android.finsky.activities.LaunchUrlHandlerActivity");
launchIntent.setComponent(comp);
// only line you need to edit is this next one
launchIntent.setData(Uri.parse("market://details?id=your.package.name")); // or "market://details?id=your.app.id"
startActivity(launchIntent);
}
You can use this on Image click:
Uri.parse("http://play.google.com/store/apps/details?id="
+ getApplicationContext().getPackageName())));
here is the code that is giving the force close error running on avd
public class MainActivity extends Activity {
Button magic;
TextView display;
int random;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
magic=(Button)findViewById(R.id.magic);
display=(TextView)findViewById(R.id.textView1);
magic.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
random = (int)Math.ceil(Math.random()*100);
display.setText("your number is"+random);
}
});
}
}
here is the code i am using even if random function or settext is not used application force closes please help
activity_main.xml not giving any error or warning..........
xml file
<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:background="#drawable/magic8ball"
android:gravity="center"
tools:context=".MainActivity" >
<android.widget.Space
android:id="#+id/space1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="144dp"
android:layout_marginTop="192dp" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="131dp"
android:layout_marginTop="171dp"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="#+id/magic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/linearLayout1"
android:layout_toRightOf="#+id/linearLayout1"
android:text="#string/Magic" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/Magic"
android:layout_alignParentRight="true"
android:layout_marginBottom="64dp"
android:layout_marginRight="74dp"
android:text="#string/Ask"
android:textAppearance="? android:attr/textAppearanceLarge"
android:textColor="#EE5533" />
</RelativeLayout>
the xml file is given where the single waring is related to the textview1 when hard coded
since the text is about to change whether it is good to set it on string.xml or hard code it ?????
For what purpose you are using following code.
**<android.widget.Space
android:id="#+id/space1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="144dp"
android:layout_marginTop="192dp" />**
This seems not available.. its working fine in the ICS devices.. but not working in Gingerbread devices.. I think that's the unusable code...
I've created a somewhat simple layout with a total of 4 buttons: 3 buttons at the bottom of the layout are side by side (in a RelativeLayout) and on huge button almost in the middle of the screen.
On Ice Cream Sandwich and Jellybean, I can click any of the buttons and everything works fine (i.e.The respective onClick functions are called) but weirdly enough on Gingerbread any of the 3 buttons at the bottom work but not the one in the middle. onClick fires off many instructions, none of which are being executed so as far as I can tell, it's not being called and I don't know why.
Code for layout is given below. Any help is greatly appreciated!
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/main_off"
android:orientation="vertical"
android:weightSum="10" >
<ImageButton
android:id="#+id/button_activate"
android:layout_width="155dp"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="170dp"
android:layout_weight="7.2"
android:background="#drawable/transparent"
android:clickable="true"
android:contentDescription="#string/app_name"
android:onClick="activate"
android:src="#drawable/transparent" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_marginTop="80dp"
android:layout_weight="2" >
<ImageButton
android:id="#+id/button_help"
android:layout_width="90dp"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_marginTop="0dp"
android:background="#drawable/transparent"
android:clickable="true"
android:contentDescription="#string/app_name"
android:onClick="openhelp"
android:src="#drawable/transparent" />
<ImageButton
android:id="#+id/button_settings"
android:layout_width="55dp"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginTop="0dp"
android:layout_toLeftOf="#+id/button_help"
android:background="#drawable/transparent"
android:clickable="true"
android:contentDescription="#string/app_name"
android:onClick="opensettings"
android:src="#drawable/transparent" />
<ImageButton
android:id="#+id/button_contact"
android:layout_width="70dp"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_marginTop="0dp"
android:layout_toRightOf="#+id/button_help"
android:background="#drawable/transparent"
android:clickable="true"
android:contentDescription="#string/app_name"
android:onClick="opencontact"
android:src="#drawable/transparent" />
</RelativeLayout>
</LinearLayout>
Activity that calls the layout (main.xml):
//bunch of imports
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout layout = (LinearLayout) findViewById (R.id.main_layout);
boolean serviceOn = isMyServiceRunning();
if(serviceOn==true) layout.setBackgroundResource(R.drawable.main_on);
else if (serviceOn==false) layout.setBackgroundResource(R.drawable.main_off);
}
#Override
protected void onResume() {
super.onResume();
LinearLayout layout = (LinearLayout) findViewById (R.id.main_layout);
boolean serviceIsOn = isMyServiceRunning();
if(serviceIsOn==true) layout.setBackgroundResource(R.drawable.main_on);
else if (serviceIsOn==false) layout.setBackgroundResource(R.drawable.main_off);
}
public void activate(View v){
LinearLayout layout = (LinearLayout) findViewById (R.id.main_layout);
Resources res = getResources();
Drawable on = res.getDrawable(R.drawable.main_on);
Drawable off = res.getDrawable(R.drawable.main_off);
if (layout.getBackground().getConstantState() == off.getConstantState()){
layout.setBackgroundResource(R.drawable.main_on);
Toast.makeText(getApplicationContext(), "App has been activated", Toast.LENGTH_SHORT).show();
turnon();
}
else if (layout.getBackground().getConstantState() == on.getConstantState()){
layout.setBackgroundResource(R.drawable.main_off);
Toast.makeText(getApplicationContext(), "App has been deactivated", Toast.LENGTH_SHORT).show();
turnoff();
}
}
}
I can run this fine on my emulator for both 2.2 and 2.3.
The only thing I can suggest is to try to remove drawables (maybe some settings there are screwing things up), or try to make your relative layout height 0dp, since you are using weight_sum
I've developed this app, everything works fine, but loading takes 4-5 seconds and I don't know why, because there is no image or internet content to be loaded, just logcat spreads about 500 messages about garbage collector. Can you tell me what am I doing wrong? here's some code:
public class HNappActivity extends SherlockFragmentActivity implements
HeadlinesFragment.OnHeadlineSelectedListener, CABNavLis{
HeadlinesFragment hnHeadlinesFragment;
int hnCatIndex = 0;
int hnArtIndex = 0;
Categories hnCurrentCat;
public String[] Rubriky = null;
int count;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_hnapp);
Rubriky = ((HNapp) this.getApplication()).getRubriky();
count=((HNapp) this.getApplication()).getCount();
hnHeadlinesFragment = (HeadlinesFragment) getSupportFragmentManager().findFragmentById(
R.id.headlines);
hnHeadlinesFragment.setOnHeadlineSelectedListener(this);
hnCatIndex = savedInstanceState == null ? 0 : savedInstanceState.getInt("catIndex", 0);
hnHeadlinesFragment.setSelectable(true);
restoreSelection(savedInstanceState);
}
void restoreSelection(Bundle savedInstanceState) {
if (savedInstanceState != null) {
setNewsCategory(savedInstanceState.getInt("catIndex", 0));
int artIndex = savedInstanceState.getInt("artIndex", 0);
hnHeadlinesFragment.setSelection(artIndex);
OnHeadlineSelected(artIndex);
}
}
activity_hnapp.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/headlines"
android:name="sk.ecopress.hn.android.HeadlinesFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.03" />
<RelativeLayout
android:id="#+id/relative_layout1"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal" >
<Button
android:id="#+id/titulka"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="0dp"
android:layout_alignParentLeft="true"
android:text="#string/titulka" />
<Button
android:id="#+id/sekcie"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_toRightOf="#id/titulka"
android:text="#string/sekcie"
android:padding="0dp" />
<Button
android:id="#+id/bookmarks"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_toRightOf="#id/sekcie"
android:text="#string/bookmarks"
android:padding="0dp" />
<Button
android:id="#+id/info"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="0dp"
android:layout_alignParentRight="true"
android:onClick="info"
android:text="#string/info" />
<Button
android:id="#+id/nastavenia"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="0dp"
android:layout_toLeftOf="#id/info"
android:onClick="settings"
android:text="#string/nastavenia" />
thanks
If the garbage collection is working hard it's because you are creating a lot of garbage :). Run over in debug line by line and see which line gets stuck.
From the code you've posted it's non of the android sdk code that generate this garbage.
My bet would be on the line:
Rubriky = ((HNapp) this.getApplication()).getRubriky();
What does it do? accessing a local file or something?