App works in >apk 17, but crashes in apk 11 device custom action bar not working - android-actionbar

This code works fine in the handset devices with android level 4.0.. but crashes with android 3.0....
The code in bold is where the error log points to... the screen shot of error log is given
public class Main extends Activity
{
ImageView villas, apartments,plots,gaButton;
#Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
//getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
<b>setContentView(R.layout.main);</b>
//getActionBar().hide();
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
villas=(ImageView)findViewById(R.id.villas);
apartments=(ImageView)findViewById(R.id.apartments);
plots=(ImageView)findViewById(R.id.plots);
}
});
initializeActionBar();
}

Related

Text box hint and text invisible in authentication UI in Cognito

When I start up the sign in activity for my app, it comes up with what should appear, with the exception of the text boxes, which have no visible hints. Also, when the user types into the text boxes, the text is invisible (probably same color as the background of the text box]
This is what happens
Heres my onCreate():
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
// Start the authentication UI
AuthUIConfiguration config = new AuthUIConfiguration.Builder()
.userPools(true)
.backgroundColor(Color.rgb(0x36, 0x89, 0x56))
.isBackgroundColorFullScreen(true)
.build();
SignInActivity.startSignInActivity(this, config);
LoginActivity.this.finish();
final IdentityManager identityManager = AWSProvider.getInstance().getIdentityManager();
// Set up the callbacks to handle the authentication response
identityManager.login(this, new DefaultSignInResultHandler() {
#Override
public void onSuccess(Activity activity, IdentityProvider identityProvider) {
Toast.makeText(LoginActivity.this,
String.format("Logged in as %s", identityManager.getCachedUserID()),
Toast.LENGTH_LONG).show();
// Go to the main activity
final Intent intent = new Intent(activity, RangingActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivity(intent);
activity.finish();
}
#Override
public boolean onCancel(Activity activity) {
return false;
}
});
}
And here are the resources I followed to make the activity:
https://docs.aws.amazon.com/aws-mobile/latest/developerguide/add-aws-mobile-user-sign-in.html
https://docs.aws.amazon.com/aws-mobile/latest/developerguide/add-aws-mobile-user-sign-in-customize.html
Thanks

ActionBar back button crash my app

I have problem with my school project when I want to back to my CurentCourseActivity using back button form action bar I have NE
Attempt to invoke virtual method 'java.util.List `com.example.pingu.mylanguages.Language.getList()' on a null object reference at
com.example.pingu.mylanguages.CurentCourseActivity.onCreate(CurentCourseActivity.java:37)`
While I use normal back button problem is not appear.
When we choose Lesson from GridView that makes a new activity. When we choose the back button from ActionBar then I have NE.
CourentCourseActivity:
public class CurentCourseActivity extends AppCompatActivity {
private Language language;
#Override
protected void onCreate(Bundle savedInstanceState) {
Log.d("s","onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_curent_course);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState!=null){
language = (Language) savedInstanceState.getSerializable("Lang");
Log.d("xx","Coś ma");
}
if (getIntent().getExtras() != null) {
language = (Language) getIntent().getSerializableExtra("Lang"); //Obtaining data
}
GridView grid = (GridView) findViewById(R.id.grid);
CurrentCourseAdapter adapter = new CurrentCourseAdapter(this, R.layout.grid_item_curent_course, language.getList());
grid.setAdapter(adapter);
grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Intent intent = new Intent(CurentCourseActivity.this,LessonActivity.class);
intent.putExtra("Lesson",(Lesson)language.getList().get(i));
startActivity(intent);
}
});
getSupportActionBar().setTitle(language.getName());
}
}
LessonActivity:
public class LessonActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lesson);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if(getIntent().getExtras()!=null){
Lesson lesson = (Lesson) getIntent().getSerializableExtra("Lesson");
getSupportActionBar().setTitle(lesson.getNamel());
}
}
}
The answer is simplest then I expect. So I need to overide this button and do it as normal back button because ActrionBar back button destroy parent activity.
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}

NAVIGATION_MODE_TABS and ViewPager not working properly in landscape orientation

I have an activity which contains a viewpager to swipe across 4 fragments.
I'm also using ActionBar.NAVIGATION_MODE_TABS to display the tabs name and allow navigating by pressing on on the tab as well as swiping
public void onCreate(Bundle savedInstanceState) {
...
this.viewPager = (ViewPager) findViewById(R.id.viewPager);
this.viewPagerAdapter = new MyViewPagerAdapter(this, getSupportFragmentManager());
this.viewPager.setAdapter(this.viewPagerAdapter);
this.viewPager.setCurrentItem(0);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Create a tab listener that is called when the user changes tabs.
final TabListener tabListener = new TabListener() {
#Override
public void onTabReselected(Tab arg0, FragmentTransaction arg1) {
}
#Override
public void onTabSelected(Tab tab, FragmentTransaction arg1) {
viewPager.setCurrentItem(tab.getPosition());
}
}
#Override
public void onTabUnselected(Tab arg0, FragmentTransaction arg1) {
}
};
// add the tabs
this.viewPager.setOnPageChangeListener(
new ViewPager.SimpleOnPageChangeListener() {
#Override
public void onPageSelected(int position) {
// When swiping between pages, select the corresponding tab.
actionBar.setSelectedNavigationItem(position);
}
});
This works fine, but when the device is in landscape orientation, the tabs are displayed as an action spinner, then the spinner content doesn't refresh anymore when swiping in the viewpager even though onPageSelected() is called with the correct position
Any idea how to fix this ?
Thanks
For now I will use the following workaround, but I'm still interested in finding a real solution.
The workaround is to force the display of the tabs even in landscape by setting the navigation mode after the tabs have been added as seen here

java.lang.NoClassDefFoundError: com.google.android.glass.app.Card

I am trying to create a sample glass application using below tools -
GDK Preview API 19
Java 6
Android 4.4.2
I have added an activity as below -
public class HelloWorldActivity extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Context con = this;
Card myCard = new Card(con);
myCard.setText("Hello, World!");
myCard.setFootnote("First Glassware for Glass");
View cardView = myCard.getView();
setContentView(cardView);
//setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
It gives an error for Card class not found, I have added the gdk.jar(21 KB) but still it throws an error. Please advise
Also I have checked the Card class code and its a stub class and does not contain implementation. Could you please provide correct gdk jar with correct implementation ?
If you are trying to make a simple HelloWorld app, you can follow THIS
I got it to work just today just by doing so. Please see my answer HERE

does not show simple Action bar in android app

I am trying to make an action bar in my app. I have already hide the default action bar but it is not showing my action bar.
I am using code from :-
http://developer.android.com/guide/topics/ui/actionbar.html
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_category, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
}
here is code for menu:-