GuidedStepFragment option is editable by default - android

I tried to use GuidedStepFragment to organize settings of my tv app. I run into with problem, that step option work like EditText field, but I don't use GuidedAction.Builder.editable() method.
Settings fragment code
public static class SettingsFragment extends GuidedStepSupportFragment {
#Override
public GuidanceStylist.Guidance onCreateGuidance(Bundle savedInstanceState) {
String title = "Настройки1";
String description = "Настройки2";
String breadcrumb = "Настройки3";
Drawable icon = getActivity().getResources().getDrawable(R.drawable.app_icon_quantum);
return new GuidanceStylist.Guidance(title, description, breadcrumb, icon);
}
#Override
public void onCreateActions(#NonNull List<GuidedAction> actions, Bundle savedInstanceState) {
actions.add(new GuidedAction.Builder()
.id(1)
.infoOnly(true)
.title("Адрес сервера")
.build());
}
}
How I add fragment
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GuidedStepSupportFragment.add(getSupportFragmentManager(), new SettingsFragment());
}
Android Studio version: Beta 4
Gradle plugin version: 2.0.0-beta4
Build tools version: 23.0.2

After some investigation I notice that these bug appears only when app running on tablet, or I try to navigate via mouse on emulator.

Related

Pass data between androidx fragments

I am simply trying to pass results from one fragment to another.
Following Android's example exactly to set up the receiving fragment:
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getParentFragmentManager().setFragmentResultListener("key", this, new FragmentResultListener() {
#Override
public void onFragmentResult(#NonNull String key, #NonNull Bundle bundle) {
// We use a String here, but any type that can be put in a Bundle is supported
String result = bundle.getString("bundleKey");
// Do something with the result...
}
});
}
for some reason android studio can't find setFragmentResultListener(). Taking a peek into the FragmentManager class, it looks like the method is missing? or is hidden...
Im using androidx.appcompat:appcompat:1.0.9
Any guidance/insight is GREATLY appreciated
solved, needed to add implementation 'androidx.fragment:fragment:1.3.0-alpha04' (or higher, i think the most recent is *-alpha07) to my build.gradle

Application Not Responding After Launching ACTION_VIEW Intent

After I successfully launching the following intent:
startActivity(new Intent(Intent.ACTION_VIEW, SOME_URL));
The browser boots up fine and loads the link, but when I try to return to my app the response is sluggish. When the app eventually launches I am met with a black screen, and finally an "Application Not Responding" dialog.
No errors in logcat, no obvious memory issues, nothing to indicate what I did wrong.
The activity that launches the intent is a pretty simple activity, with one fragment:
public class LinkActivity extends AppCompatActivity {
#BindView(R.id.toolbar) Toolbar mToolbar;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_link);
ButterKnife.bind(this);
setSupportActionbar(mToolbar);
setupActionBar();
if(savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.content, LinkFragment.newInstance()).commit();
}
}
private void setupActionBar() {
ActionBar actionBar = getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
}
}
}
And the fragment uses a combination of RxJava, RetroFit and Dagger ‡ to load a list of links:
public class LinkFragment extends Fragment {
#Inject RestService mRestService;
#BindView(R.id.recycler) RecyclerView mRecyclerView;
public static LinkFragment newInstance() {
return new LinkFragment();
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_link, container, false);
Injector.getContextComponent().inject(this);
ButterKnife.bind(this, view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext());
mRecyclerView.addItemDecoration(new DividerDecoration(getContext());
mRecyclerView.setAdapter(new LinkAdapter(new ArrayList<>()));
mRestService.getLinks()
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::onNext, this::onError);
return view;
}
private void onNext(Response<Link> response) [
LinkAdapter adapter = new LinkAdapter(response.data());
adapter.setOnItemClickListener(this::onItemSelected);
mRecyclerView.swapAdapter(adapter, false);
}
private void onError(Throwable throwable) {
Timber.w(throwable, "Failed to obtain links");
}
private void onItemSelected(int position, View view, Link link) {
startActivity(new Intent(Intent.ACTION_VIEW, link.getUri());
}
}
After finding two similar questions with similar answers (How to spot app freeze causes when app is returning from pause state?, Android App freezes after implementing Google Firebase) suggesting that adding Google Play Services might be the culprit, I started to investigate.
Both answers suggested that I remove the following dependency:
compile 'com.android.gms:play-services:9.0.2'
But my application uses that dependency, as well as the following play services dependencies:
compile 'com.google.android.gms:play-services-wearable:9.0.2'
compile 'com.google.android.gms:play-services-gcm:9.0.2'
compile 'com.google.android.gms:play-services-location:9.0.2'
compile 'com.google.android.gms:play-services-analytics:9.0.2'
Previously, I had been using classes from both the core play services library and the wearable play services library in both my mobile module and my wear module. But I noticed that I had removed the need for the wear module in my mobile module, so I removed it from the mobile module (while keeping it in the wear module). Somehow, this fixed the issue.
I have no clue why, so if anyone has any thoughts, please share.

There's some error when android loading layout,but have no effective on running

So,that's the logcat information I get.The app still can run,but I want to know the reason why I get this error.
I don't understand why i get this so i even don't know how to ask.
09-26 07:13:33.510 18533-18533/com.gongxxing.gongxxing0921 D/AccessibilityManager﹕ setStateLocked: wasEnabled = false, mIsEnabled = false, wasTouchExplorationEnabled = false, mIsTouchExplorationEnabled = false, wasHighTextContrastEnabled = false, mIsHighTextContrastEnabled = false
java.lang.Throwable: setStateLocked
at android.view.accessibility.AccessibilityManager.setStateLocked(AccessibilityManager.java:553)
at android.view.accessibility.AccessibilityManager.tryConnectToServiceLocked(AccessibilityManager.java:636)
at android.view.accessibility.AccessibilityManager.<init>(AccessibilityManager.java:226)
at android.view.accessibility.AccessibilityManager.getInstance(AccessibilityManager.java:206)
at android.view.View.setFlags(View.java:9941)
at android.view.ViewGroup.initViewGroup(ViewGroup.java:536)
at android.view.ViewGroup.<init>(ViewGroup.java:525)
at android.view.ViewGroup.<init>(ViewGroup.java:520)
at android.view.ViewGroup.<init>(ViewGroup.java:516)
at android.view.ViewGroup.<init>(ViewGroup.java:512)
at android.widget.FrameLayout.<init>(FrameLayout.java:119)
at com.android.internal.policy.impl.PhoneWindow$DecorView.<init>(PhoneWindow.java:2341)
at com.android.internal.policy.impl.PhoneWindow.generateDecor(PhoneWindow.java:3639)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:4026)
at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:2052)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:148)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:60)
at com.gongxxing.gongxxing0922.MainActivity.onCreate(MainActivity.java:27)
at android.app.Activity.performCreate(Activity.java:6142)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1115)
I am sorry for forgetting paste the Main activity.
The line 27 is
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
super.onCreate(savedInstanceState); is the line 27.
Sorry to answer this old question,but i solved this exception in my project.
I think what leads to the exception is we are using the context of our activity when it is creating.
My code is something like:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
regToWx();
}
private void regToWx(){
IWXAPI api;
api = WXAPIFactory.createWXAPI(this, Constants.WX_APP_ID, true);
api.registerApp(Constants.WX_APP_ID);
String text = "123";
WXTextObject textObj = new WXTextObject();
textObj.text = text;
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = textObj;
msg.description = text;
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.scene = SendMessageToWX.Req.WXSceneSession;
req.transaction = String.valueOf(System.currentTimeMillis());
req.message = msg;
api.sendReq(req);
}
As the regToWx method need to create something by this which is the context,but i think the context can not be used(in some ways) inside onCreate method. So I just put it in a thread and then the problem is solved.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
new Thread(new Runnable() {
#Override
public void run() {
regToWx();
}
}).start();
}
So try to find out what you have done with your context in onCreate method, put these code out of the it or just make the code asynchronous.
I was getting the same error. I found out that it is due to the attribute android:sharedUserId="com.something" that I was using in the manifest files.
Suppose version 1 of your application has android:sharedUserId in the manifest and initialises a ContentProvider.
Now, suppose in version 2, you remove the android:sharedUserId from the manifest and try to access the ContentProvider created in version 1.
In this case, the recent version will not be able to access the ContentProvider created in version 1.

Few memory leaks in Facebook SDK

I tried to make social module for my app, something like wrapper, that will contain Google+,Facebook and twitter integration templates.
Now I am working with Facebook SDK and decided to use LeakCanary in my app, after successful log in I rotated the device few times, and see the following information:
Here is MainActivity.class:
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setFragment();
}
private void setFragment(){
getSupportFragmentManager()
.beginTransaction()
.add(R.id.container, new MainFragment())
.commit();
}
}
Here is how I log in to Facebook:
public void configureFacebook(#NonNull Fragment fragment,
#Nullable String permissions, #Nullable String requestFields) {
setPermissionAndRequestFields(permissions, requestFields);
loginManager = LoginManager.getInstance();
callbackManager = CallbackManager.Factory.create();
loginManager.registerCallback(callbackManager, facebookCallback);
loginManager.logInWithReadPermissions(fragment, Arrays.asList(this.permissions));
loginManager=null;
}
I tried log in using Login Button too, in this case I catch this issue and new one, with following info:
Here is how I log in using LoginButton.class:
public void configureFacebook(#NonNull Fragment fragment,
#Nullable String permissions, #Nullable String requestFields, #NonNull LoginButton button) {
callbackManager = CallbackManager.Factory.create();
setFbButton(button);
setPermissionAndRequestFields(permissions, requestFields);
fbButton.setFragment(fragment);
fbButton.setReadPermissions(this.permissions);
fbButton.registerCallback(callbackManager, facebookCallback);
}
I can't figure out how to fix those issues. What I am doing wrong?
UPDATE: Leak in Facebook Activity.class has been shown without the rotation device.
Looks like they may have fixed this for Facebook SDK Version 4.2.0. see here
Updating the Facebook SDK may be the solution to your problem.
I updated it to 4.7.0 and I think this issue has been fixed.
Fixed in 4.10. I tried without facebook app and checked with memory manager.

Code works in one Android project but won't compile in another

The following code was copied from project one and pasted into project two. No errors in project one. In project two I get:
The method onClick(View) of type new View.OnClickListener((){} must override a superclass method
implements androd.view.View.OnClickListener.onClick
The project settings look the same, but I must be missing something.
private Button mCompany = null;
public class About extends Activity{
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
setTitle(R.string.title_about);
mCompany = (Button)findViewById(R.id.about_company_button);
mCompany.setOnClickListener( new OnClickListener() {
#Override
public void onClick(View arg0) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(getResources().getString(R.string.app_company_website)));
startActivity(intent);
}
});
Found a solution on another site but I would like to know why this will work. It said to comment out the Override. Actually, it now compiles fine but crashes when the about item is clicked.

Categories

Resources