SelectionFragment class missing - Android based Facebook development - android

I've created a project where I want to have a list of friends returned. I'm following this tutorial and at section 2c I have realized that my build does not contain a SelectionFragment class. Where online could I download this class, or does anyone have the code for this class? Thank you.

maybe here SelectionFragment.java on github

My guess this class needed to be created a little bit earlier in tutorial.
Choose "Step 1b" link in right column of a page.
https://developers.facebook.com/docs/android/scrumptious/authenticate#step1b
It says like:"Create a new fragment class in your package for the authenticated UI. Name this class ''SelectionFragment'' and make its superclass Fragment."

Related

ViewModelProviders.of(getActivity()) "Cannot resolve method of(android.app.Activity)"

I'm currently trying to share data between my two fragments with the help of a view model Android ViewModels.
In the this article they use "ViewModelProviders.of(getActivity()).get(SharedViewModel.class);" in the Fragment to get the model.
My Problem is, that when I write the exact same line into my fragment, I get a "Cannot resolve method of(android.app.Activity)" error
model = ViewModelProviders.of(getActivity()).get(UserAccountViewModel.class);
Can some one help me with this ?
ViewModelProviders requires that you use FragmentActivity (or something derived from it), not Activity, as the base class of your activities.
You might also get a similiar error like Cannot resolve method 'of(android.support.v4.app.FragmentActivity)' from ViewModelProviders.of(getActivity()) if you were trying to import androidx in your gradle file when your app is still using android.support.v4
This is different to the question being asked but is in the same ballpark and ranks first in Google when I had the problem, so I'm posting it!
Just cast getActivity() to specific activity. It works for me. For example:
model = ViewModelProviders.of((MainActivity)getActivity()).get(UserAccountViewModel.class);

What is the meaning of putting class name inside the brackets?

While observing an existing android application, I encountered this line of code:
((StoredVariables)this.getApplication()).getId
Why we are using this? What is the outcome of the code? Does it returns previously stored values from sharedPreference? No documentation found on internet to get an idea about it. Please explain.
You are probably a little newbie in Java also
I'm not sure about what is "this" in this.getApplication() and what the StoredVariable is, since it is not an android class...
But here are recommendations for you:
Look for StoredVariable in your class in imports section. You can find something like import my.project.StoredVariable;
Open the class (I'm 80% sure it will be interface) to see the class (this is already answer to your question)
See getId() method there
To know more about usage of StoredVariables. If this line of code is placed inside class that extends some Activity (e.g. AppCompatActivity, Activity e.t.c.)
Open AndroidManifest.xml and look into <application> tag to find android:name in there. Open class with that name (ctrl + click or cmd + click on class name)
This class is extending Application class (or subclass) and implementing StoredVariables interface, or it is directly StoredVariable class

Where can I find the source code of Android class SQLiteOpenHelper?

I want to take a look at the Android SQLiteOpenHelper class implementation, can somebody points me the location?
The link you want is:
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/database/sqlite/SQLiteOpenHelper.java
But even better let me share a great tip:
This extension for Google Chrome
https://chrome.google.com/webstore/detail/android-sdk-search/hgcbffeicehlpmgmnhnkjbjoldkfhoin?hl=en-GB adds the ad (as in Android Developer) keyword to your searchbar so you can type ad TextView and it will bring you directly to TextView on this example AND will add a link "View Source" next to the class name inside the site https://developer.android.com/reference so for any class you want to see the source it's just a click away.
You can find all the existing versions here: http://grepcode.com/search?query=SQLiteOpenHelper&n=

Eclipse SDK android : The declared package does not match the expected package

I've read through similar errors however I'm confused as to how to avoid this error when working with the ADT plugin for eclipse.
I'm attempting to follow this tutorial on how to create a Grid view of images:
http://developer.android.com/guide/topics/ui/layout/gridview.html
Step five simply states open Open HelloGridView.java, however I'm not sure if I should just create a new class, or activity.
"Step five:
Create a new class called ImageAdapter that extends BaseAdapter:
I've tried both creating a new class and creating a new activity. When i created an activity I made com.example.HelloGridView the hierarchy. But I don't think this is right and I don't think these should be activities. and I receive this error:
The declared package "" does not match the expected package "com.example.hellogridview"
in the HelloGridView.java and ImageAdapter.java
What I really want to know is how should I create a new class like in step four and step 5?
(also I'm very new to android I've gone through the android training "get started" but still feel slightly clueless, Where should I go from here?)
Any help would be greatly appreciated!!
Your new class HelloGridView need to must be under your application package com.example.hellogridview.
I get this error when my code path does not match the package name.
For example, if your package name is com.whatever.myapplication, then the class should be under /yourworkspacedirectory/com/whatever/myapplication folder.

Add enclosing class to Eclipse template

I do many logging in Android, so I want to create an Eclipse template for quick logging. This is my template :
Name: log
Pattern: Log.d("${enclosing_package}", "${enclosing_method}" +${cursor});
I need to add enclosing class to log info but there is no $enclosing_class. Is there any way to get enclosing_class?
Thanks!
You want ${enclosing_type}.
The complete list of template variables is available in Eclipse help.

Categories

Resources