How to start new activity using startActivity(intent) in Custom RecyclerView Adapter? - android

I am having a CustomRecyclerViewAdapter.class file in which I have implemented the below method.
public void onBindViewHolder(RecyclerViewHolder viewHolder, int position)
{
viewHolder.title.setText(mData.get(position).text);
//viewHolder.icon.setBackgroundColor(Color.parseColor(mData.get(position).color));
viewHolder.setClickListener(new RecyclerViewHolder.ClickListener(){
#Override
public void onClick(View v, int position, boolean isLongClick) {
if (isLongClick) {
// View v at position pos is long-clicked.
Toast.makeText(v.getContext(), "Hey you just hit item" + position, Toast.LENGTH_SHORT).show();
}else {
// View v at position pos is clicked.
//how to start a new activity here
Toast.makeText(v.getContext(),"Hey you just hit item" + position,Toast.LENGTH_SHORT).show();
}
}
});
}
So how i can start the new activity in the else block above.
Group.class
public class Group extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);//line no. 16 which is indicated in logcat
setContentView(R.layout.group);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
This is my error logcat.....
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.trueblueoperator.samplerecyclerview/com.trueblueoperator.samplerecyclerview.Group}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
at com.trueblueoperator.samplerecyclerview.Group.onCreate(Group.java:16)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Thanks for your time.

You can use any View to it.
getContext() method provides almost activity methods because Activity extends Context.
v.getContext().startActivity(intent);

Related

Getting NullPointerException while displaying ListView

I was trying to make a ListView of reminder notes. But when I try to save it and display it in a ListView, app crashes with this error/exception. saveNote method is called when you press save button. Any help is appreciated.
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch(id) {
case R.id.add_reminder : {
et = (EditText)findViewById(R.id.new_note);
et.setVisibility(View.VISIBLE);
note = et.getText().toString();
i++;
Button save_button = (Button) findViewById(R.id.button_save);
save_button.setVisibility(View.VISIBLE);
}
default : return super.onOptionsItemSelected(item);
}
}
public void saveNote(View view) {
String[] notes = new String[20];
notes[i] = note;
listView = (ListView) findViewById(R.id.list);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1,notes);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//Clicked item index
int itemPosition = position;
//Clicked item value
String itemNote = (String) listView.getItemAtPosition(position);
//Alert
Toast.makeText(getApplicationContext(), "Position :" + itemPosition + " ListItem : " + itemNote, Toast.LENGTH_LONG).show();
}
});
Logcat
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:4020)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4015)
            at android.view.View.performClick(View.java:4780)
            at android.view.View$PerformClick.run(View.java:19866)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5257)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
at com.cokosofts.pramith.reminder.MainActivity.saveNote(MainActivity.java:69)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at android.view.View$1.onClick(View.java:4015)
            at android.view.View.performClick(View.java:4780)
            at android.view.View$PerformClick.run(View.java:19866)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5257)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
The main cause which I found from the Logs is ListView is null. Please check one more time if the listView is empty or not? Also what is notes[i] = note ??
I think in each Save button click you are finding ListView and the setting Adapter each time. This is not a good approach from my point of view. You should set the adapter very first time and next time just update your adapter data and call notifyDataSetChanged();
Debug and find out why your ListView was not found on your layout (was null).
Problem is with following line:
listView = (ListView) findViewById(R.id.list);
Please check whether your xml has ListView widget with id as 'list' .
If id is different in XML it will result in a NULL object reference. When you call
listView.setAdapter(adapter)
It will give a NULL pointer exception.

OnClickListener inside the fragment gives Null Pointer Exception

I have a image button to delete that particular row inside a listview in a fragment.When I run the activity from main activity it gives NPE.
Here is the logcat output
03-10 12:29:36.647 2525-2525/com.restaurantmgmt.dcode1.restaurantms E/libprocessgroup﹕ failed to make and chown /acct/uid_10007: Read-only file system
03-10 12:29:50.351 2525-2525/com.restaurantmgmt.dcode1.restaurantms E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.restaurantmgmt.dcode1.restaurantms, PID: 2525
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.restaurantmgmt.dcode1.restaurantms/com.restaurantmgmt.dcode1.restaurantms.menu}: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
at com.restaurantmgmt.dcode1.restaurantms.menu.onCreate(menu.java:18)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageButton.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.restaurantmgmt.dcode1.restaurantms.SidePanelFragment.onCreateView(SidePanelFragment.java:45)
at android.app.Fragment.performCreateView(Fragment.java:2053)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:870)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1045)
at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1147)
at android.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2116)
at android.app.Activity.onCreateView(Activity.java:5282)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
            at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
            at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
            at com.restaurantmgmt.dcode1.restaurantms.menu.onCreate(menu.java:18)
            at android.app.Activity.performCreate(Activity.java:5933)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Here is the relevant code from the SidePanelActivity
public class SidePanelFragment extends android.app.Fragment implements View.OnClickListener {
ListView list1;
Items addedItems=null;
ImageButton btnDelete;
Items[] addedItms=new Items[100];
//Items[] addedItms=null;
ArrayList<Items> itemsArray=null;
ItemsAdapter1 adapter=null;
int countSideList=0;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view =inflater.inflate(R.layout.fragment_side_panel,container,false);
list1=(ListView)view.findViewById(R.id.listViewSide);
btnDelete=(ImageButton)view.findViewById(R.id.btndelete);
itemsArray= new ArrayList<Items>();
btnDelete.setOnClickListener(this);
return view;
}
#Override
public void onClick(View v) {
Toast.makeText(getActivity(),"btndelete clicked",Toast.LENGTH_LONG);
}
}
And here is the activity which has the fragment
public class menu extends ActionBarActivity implements OnAddItemPressed{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
int screenOrien=getResources().getConfiguration().orientation;
if(screenOrien== Configuration.ORIENTATION_PORTRAIT) {
hideSidePanel();
}
else
{
}
}
private void hideSidePanel() {
View side=findViewById(R.id.side_panel);
if(side.getVisibility()==View.VISIBLE)
{
side.setVisibility(View.GONE);
}
}
#Override
public void onAddItemPressed(Items item){
FragmentManager manager= getFragmentManager();
SidePanelFragment sideObj= (SidePanelFragment) manager.findFragmentById(R.id.side_panel);
sideObj.getAddedItems(item);
}
}
I have set a breakpoint at btnDelete.setOnClickListener(this);
and btnDelete is null in the debug window at that breakpoint.
Try this way :
#Override
public void onClick(View v) {
switch (v.getId()){
case R.id.btndelete:
Toast.makeText(getActivity(),"btndelete clicked",Toast.LENGTH_LONG);
break;
}
Also try to replace your implements View.OnClickListener to implements OnClickListener
Make sure this btndelete id is on your fragment_side_panel.xml

Dagger - No inject registered for members?

I have dagger setup and defined injectables correctly, but getting the following errpr:
I saw a couple of similar thread, but the answers didn't solve this
java.lang.IllegalArgumentException: No inject registered for members/com.aryaxt.app.Pages.LoginActivity. You must explicitly add it to the 'injects' option in one of your modules.
Module
#Module(library = true, injects = {
LoginActivity.class
})
class MyModule {
private final Context context;
public MyModule() {
}
#Provides #Singleton
IAuthService provideAuthService() {
return new AuthService();
}
}
Application
public class MyApplication extends Application {
private ObjectGraph objectGraph;
#Override
public void onCreate() {
super.onCreate();
objectGraph = ObjectGraph.create(new MyModule());
}
public ObjectGraph getObjectGraph() {
return objectGraph;
}
}
Activity
public class LoginActiity extends ActionBarActivity {
#Inject
IAuthService authService;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((MyApplication) getApplication()).getObjectGraph().inject(this);
}
}
EDIT:
02-03 07:54:43.934 3305-3305/com.aryaxt.MyApp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.aryaxt.MyApp, PID: 3305
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aryaxt.MyApp/com.aryaxt.MyApp.Pages.LoginActivity}: java.lang.IllegalArgumentException: No inject registered for members/com.aryaxt.MyApp.Pages.LoginActivity. You must explicitly add it to the 'injects' option in one of your modules.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IllegalArgumentException: No inject registered for members/com.aryaxt.MyApp.Pages.LoginActivity. You must explicitly add it to the 'injects' option in one of your modules.
at dagger.ObjectGraph$DaggerObjectGraph.getInjectableTypeBinding(ObjectGraph.java:302)
at dagger.ObjectGraph$DaggerObjectGraph.inject(ObjectGraph.java:279)
at com.aryaxt.bobber.Pages.BaseActivity.onCreate(BaseActivity.java:18)
at com.aryaxt.bobber.Pages.LoginActivity.onCreate(LoginActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Android - Activity transition crash with ActionBarActivity

I'm currently trying to implement Material Design activity transitions. For a reason i really don't know, it crashes. Can someone give me a clue? (I don't know if it's important, but inside my MainActivity, i've a ViewPager with Fragments from which I try to start the next Activity)
Thanks a lot for your help.
My code:
public class MainActivity extends ActionBarActivity implements ActionBar.TabListener {
(...)
#Override
protected void onCreate(Bundle savedInstanceState) {
Log.i("TAAG", "MainActivity::onCreate1");
super.onCreate(savedInstanceState);
Log.i("TAAG", "MainActivity::onCreate2");
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
Log.i("TAAG", "MainActivity::onCreate3");
setContentView(R.layout.activity_main);
Log.i("TAAG", "MainActivity::onCreate4");
(...)
}
Here are the logs:
11-13 18:12:36.442 1098-1098/I/TAAG﹕ MainActivity::onCreate1
11-13 18:12:36.544 1098-1098/I/TAAG﹕ MainActivity::onCreate2
11-13 18:12:36.559 1098-1098/E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: mypackage, PID: 1098
java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackage/mypackage.MainActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:301)
at mypackage.MainActivity.onCreate(MainActivity.java:42)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Try calling getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); before super.onCreate().

How to tackle this RuntimeException?

I'm not getting this issue but a friend is so he sent me the stack trace as he lives too far away for me to check his device. This issue seems ambiguous to me so I'm not sure where to check first. What should I do?
note: I've attached my MainActivity.onCreate below this trace:
java.lang.RuntimeException: Unable to start activity ComponentInfo{xxxx.android.phone.xxxx/xxxx.android.phone.xxxx.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class shared.ui.actionscontentview.ActionsContentView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class shared.ui.actionscontentview.ActionsContentView
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Activity.setContentView(Activity.java:2144)
at xxxx.android.phone.xxxx.MainActivity.onCreate(MainActivity.java:145)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Activity.setContentView(Activity.java:2144)
at xxxx.android.phone.xxxx.MainActivity.onCreate(MainActivity.java:145)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.youtube.api.service.START }
at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:1674)
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1773)
at android.app.ContextImpl.bindService(ContextImpl.java:1751)
at android.content.ContextWrapper.bindService(ContextWrapper.java:538)
at com.google.android.youtube.player.internal.r.e()
at com.google.android.youtube.player.YouTubePlayerView.a()
at com.google.android.youtube.player.YouTubeBaseActivity$a.a()
at com.google.android.youtube.player.YouTubePlayerView.initialize()
at xxxx.android.phone.xxxx.MainActivity.initYouTubePlayer(MainActivity.java:509)
at xxxx.android.phone.xxxx.layout.MainContainer.onFinishInflate(MainContainer.java:73)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:814)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at shared.ui.actionscontentview.ActionsContentView.<init>(ActionsContentView.java:217)
at shared.ui.actionscontentview.ActionsContentView.<init>(ActionsContentView.java:136)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Activity.setContentView(Activity.java:2144)
at xxxx.android.phone.xxxx.MainActivity.onCreate(MainActivity.java:145)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
MainActivity.onCreate
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
MainActivity.instance = this;
this.className = this.getClass().getSimpleName();
// get login credentials
SharedPreferences settings = getSharedPreferences(xxxx.PREFS, 0);
xxxx.instance.currentUserEmail = settings.getString(xxxx.PREFS_KEY_SAVED_EMAIL, "");
xxxx.instance.currentUserPassword = settings.getString(xxxx.PREFS_KEY_SAVED_PASSWORD, "");
if(MainActivity.CACHING_ENABLED) {
// set up image cache
ImageCache.ImageCacheParams imageCacheParams = new ImageCache.ImageCacheParams(getApplicationContext(), IMAGE_CACHE_DIR);
// Set image memory cache to 1/10th of mem class
imageCacheParams.setMemCacheSizePercent(this, 0.1f);
MainActivity._imageCache = new ImageCache(imageCacheParams);
// set up xml cache
XMLCache.XMLCacheParams xmlCacheParams = new XMLCache.XMLCacheParams(this, XML_CACHE_DIR);
// Set xml memory cache to 1/10th of mem class
xmlCacheParams.setMemCacheSizePercent(this, 0.1f);
MainActivity._xmlCache = new XMLCache(xmlCacheParams);
this.checkCacheFreshness();
}
Session session = Session.getActiveSession();
if (session == null) {
if (savedInstanceState != null) {
session = Session.restoreSession(this, null, statusCallback, savedInstanceState);
}
if (session == null) {
//session = new Session.Builder(this).setApplicationId(getResources().getString(R.string.facebook_app_id)).build();
session = new Session(this);
}
Session.setActiveSession(session);
if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
}
}
setContentView(R.layout.app_container);
navSlider = (ActionsContentView) findViewById(R.id.actionsContentView);
// use a tree observer and a global layout listener to get the available screen size and height -DJL
final RelativeLayout fullScreenLayout = (RelativeLayout) findViewById(R.id.fullScreenLayout);
ViewTreeObserver vto = fullScreenLayout.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
public void onGlobalLayout() {
//remove listener to ensure only one call is made.
fullScreenLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
xxxx.instance.height = fullScreenLayout.getHeight();
xxxx.instance.width = fullScreenLayout.getWidth();
Log.v(xxxx.TAG, "Height: " + xxxx.instance.height);
Log.v(xxxx.TAG, "Width: " + xxxx.instance.width);
// Once we have the dimensions we load the featured page
Navigation.instance.featuredBtn.performClick();
};
});
// Load the quick tutorial activity if it has never been loaded
SharedPreferences prefs = getSharedPreferences(xxxx.PREFS, 0);
// If the app has been updated, show the tutorial again
if (xxxx.wasUpdated(getBaseContext())) {
SharedPreferences.Editor editor = prefs.edit();
editor.putString(xxxx.PREFS_KEY_TUTORIAL_SHOWN, "false");
editor.commit();
}
boolean tutShown = Boolean.parseBoolean(prefs.getString(xxxx.PREFS_KEY_TUTORIAL_SHOWN, null));
//tutShown = false; // uncomment to display the tutorial every launch for testing
if(!tutShown) {
Intent intent = new Intent(this, TutorialActivity.class);
startActivity(intent);
// update the tutorial show preference
SharedPreferences.Editor editor = prefs.edit();
editor.putString(xxxx.PREFS_KEY_TUTORIAL_SHOWN, "true");
editor.commit();
}
boolean shouldPromptCheck = true;
Bundle bundle = this.getIntent().getExtras();
if(bundle != null) {
shouldPromptCheck = bundle.getBoolean(xxxx.KEY_SHOULD_PROMPT_CHECK, true);
}
if(shouldPromptCheck) {
xxxx.instance.performVersionCheck(this);
}
}
I updated my versions of the Youtube SDK & Google Analytics SDKs and viola.

Categories

Resources