PreferenceActivity vs. PreferenceFragment when writing App for all Versions - android-preferences

I have a problem trying to use preferences with my App.
I could not find a solution in similar posts here.
My App shall support android versions from 8 to 19.
With Android Developer I found this:
If your app supports versions of Android older than 3.0 (API level 10 and lower), you must build the activity as an extension of the PreferenceActivity class.
On Android 3.0 and later, you should instead use a traditional Activity that hosts a PreferenceFragment that displays your app settings. However, you can also use PreferenceActivity to create a two-pane layout for large screens when you have multiple groups of settings.
So what to do if I would not support neither API's up to level 10 and not higher nor API's only higher than 10?
I have tried to use the PreferenceActivity class together with addPreferencesFromRessource(R.id....)
But than I've got this:
package com.example.wbslideshow;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class initialpath extends PreferenceActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
where addPreferencesFromResource is seen as addPreferencesFromResource because of the deprecated status.
together with this explanation:
The method addPreferencesFromResource(int) from the type PreferenceActivity is deprecated
What can I do? I think due to my API's level I can not use also PreferenceFragment which I would like to prefer. Any idea is appreciated.

Use the deprecated functions. They are still working but should not be considered state of the art. There is no option since you want to support older versions without the new possibilities. You could think about switching your project to newer APIs only.

Related

How to tell if react is used in a webapp?

In a webapp with javascript minified, is there a way to tell if a webapp uses reactjs using developer console?
You can check by just using typeof:
typeof React
But this will only verify on the page you're currently on. Nowadays, app consists of multiple environments, frameworks, etc. You may use some extension that will tell you what framework is being used in the application. For eg. check builtWith.

Codename one map component does not let me input longitude and lattidude (+ permissions)

1st question:
I am trying to use the map component from codename one Theme. However, every time i put longitude and lattitude, it resets to 0.0. How can i change that from inside the theme?
2nd question, if possible: How do i show permissions, in order to enable using your own location? It is automatic when I use the map component, but not for other components.
When i try to use web view with google map, it does not let me put my own location.
You are using the old GUI builder which is no longer maintained. I would recommend switching to the new GUI builder or using handcoding. Notice you might be better off starting a new project as the new GUI builder is VERY different.
MapComponent is also deprecated in favor of native maps those are accessible from code and are far superior on the device... The Uber clone app was built using native maps.
Location prompts are automatic when you use the LocationManager API. You can enable them in the simulator to see how it feels on the device. You can then use the JavaScript interop to pass your location to embedded HTML.

Class Library(.Net Core) VS Class Library(Portable for iOS,Android and Windows)

I want to develop an API using ASP.NET core web api, the solution contains 3 projects of type class library and 1 projects of type Web api (For Separation of Concern), My API should be consumable from xamarin and angular.
What type of class library should I use :
Class Library(.Net Core) OR Class Library(Portable for iOS,Android and Windows)
I'am using vs 2015 update 3
Class Library Types
Generally speaking as mentioned in the comments NetStandard is the way to go if you're trying to share between an AspNetCore project and a Xamarin Project.
The defacto standard of new projects is NetStandard1.4 which while perfectly consumable by Xamarin.iOS and Xamarin.Android, is not going to be consumable by a PCL in your project. In order to share code between the API and a PCL for Xamarin you will need to change the NetStandard version based on what PCL Profile you're using. You can find more information in the docs from Microsoft, but here is the key:
Profile 78 & Profile 259 - need NetStandard1.0
Profile 111 - can use NetStandard1.0 or NetStandard1.1

What's the advised way to resume / pause a Codename One app with native implementation?

I am developping a mobile Codename One app (targeting Android for now, iOS then) that uses advanced camera features. Thus I need to use the native interface and implementation.
During the app lifecycle there is a need to release the camera (eg when the user switches from my app to another) which refers to onPause() in the Android world and to initialize the camera back again (eg when the user starts or goes back to my app) which referst to onCreate() in the ANdroid world.
So far when "pausing" and "resuming" my app I've used CN1 stop() and start() method from the main class where there I call a method from the native interface. But if you read the native GoogleMaps demo you'll see that they directly use onPause() and onResume() in the native implementation after adding a LifecycleListener during initialization.
Consequently which approach should be used for my next projects involving native interfaces ?
Any hint appreaciated!
Since this will probably apply to native implementations in other OS's I would just use stop()/start() and offer a method within my native implementation for pause/resume.
This will allow you to test that in the simulator, the more code you have on the Codename One side (as opposed to native) the easier it will be.

What is the alternate way for "Request" class/object in .NET core?

I am migrating an existing ASP.NET Web API 2 project to ASP.NET Core. While migrating I am unable to find this.Request object. Can anyone help me solve out this issue?
This question was asked here, but since ASP.NET Core was still probably in an RC state then, I figured I'd answer here instead of referring to there because there is some stuff that's obsolete or completely gone from the official release.
Assuming your controller class inherits from Controller (or more specifically, ControllerBase) then it does have a this.Request property as you can see here and here. As Pawel noted, you can also access it from the this.HttpContext property.
The request's URL is broken up into several properties on HttpRequest. You can access the URL in a friendlier API by adding using Microsoft.AspNetCore.Http.Extensions; which gets you access to the following extension methods:
GetDisplayUrl()
GetEncodedUrl()
As far as the query string, HttpRequest provides QueryString and Query properties for you to interact with.
Side note: I just created an app from scratch targeting ASP.NET Core on .NET Core for the first time on this laptop, and it took a while for the Intellisense to work for the Request property, so I'm wondering if that could have been your issue.
You need to override your class like this to get this.Request
public partial class _Default : System.Web.UI.Page

Resources