• Breaking News

    Wednesday, October 27, 2021

    Android Dev - Anyone tried the M1 Pro/Max with AS yet?

    Android Dev - Anyone tried the M1 Pro/Max with AS yet?


    Anyone tried the M1 Pro/Max with AS yet?

    Posted: 27 Oct 2021 03:57 AM PDT

    How is it?

    submitted by /u/ursusino
    [link] [comments]

    FastKV - A better KV storage component

    Posted: 26 Oct 2021 07:14 PM PDT

    FastKV is an efficient and reliable key-value storage component written with Java.

    It can be used on platforms with JVM environment such as Android.

    1. Features

    • Efficient
    1. Binary coding: the size after coding is much smaller than text coding such as XML;
    2. Incremental update: FastKV records the offset of each key-value relative to the file, updating can be written directly at the right location.
    3. By default, data is recorded with mmap . When updating data, it can be written directly to memory without IO blocking.
    4. For a value which length is larger than the threshold, it will be written to another file separately, only it's file name will be cached. In that way, it will not slow down other key-value's accessing.
    • Support multiple writing mode
    1. In addition to the non-blocking writing mode (with mmap), FastKV also supports synchronous blocking and asynchronous blocking (similar to commit and apply of SharePreferences).
    • Support multiple types
    1. Support primitive types such as Boolean / int / float / long / double / string;
    2. Support ByteArray (byte []);
    3. Support storage objects.
    4. Built in encoder with Set<String> (for compatibility with SharePreferences).
    • Easy to use
    1. FastKV provides rich API interfaces, including getAll() and putAll() methods, it is convenient to migrate the data of frameworks such as sharepreferences to FastKV.
    • Stable and reliable
    1. When FastKV writes data in non-blocking way (mmap), it writes two files one by one, to ensure that at least one file is complete at any time;
    2. FastKV checks the integrity of the files when loading, if one file is incomplete, it will be restored with another file which is complete.
    3. If mmap API fails, it will be degraded to the blocking I/O; and it will try to restore to mmap mode when reloading.
    • Simple code
    1. FastKV is implemented in pure Java and the jar package is less than 40K.

    2. Getting Start

    • Import

    FastKV had been publish to Maven Central:

    dependencies { implementation 'io.github.billywei01:fastkv:1.0.4' } 
    • Initialization

    Initialization is optional.

    You could set log callback and executor as needed.

    It is recommended to pass in your own thread pool to reuse threads.

    The log interface provides three levels of callbacks.

     public interface Logger { void i(String name, String message); void w(String name, Exception e); void e(String name, Exception e); } 
    • Read/Write

    Basic case:

     FastKV kv = new FastKV.Builder(path, name).build(); if(!kv.getBoolean("flag")){ kv.putBoolean("flag" , true); } 

    Sava custom object:

     FastKV.Encoder<?>[] encoders = new FastKV.Encoder[]{LongListEncoder.INSTANCE}; FastKV kv = new FastKV.Builder(path, name).encoder(encoders).build(); List<Long> list = new ArrayList<>(); list.add(100L); list.add(200L); list.add(300L); kv.putObject("long_list", list, LongListEncoder.INSTANCE); List<Long> list2 = kv.getObject("long_list"); 

    In addition to supporting basic types, FastKV also supports writing objects. You only need to pass in the encoder of the object when building FastKV instances.

    The encoder is an object that implements FastKV.Encoder.

    For example, the implementation of LongListEncoder like this:

    public class LongListEncoder implements FastKV.Encoder<List<Long>> { public static final LongListEncoder INSTANCE = new LongListEncoder(); @Override public String tag() { return "LongList"; } @Override public byte[] encode(List<Long> obj) { return new PackEncoder().putLongList(0, obj).getBytes(); } @Override public List<Long> decode(byte[] bytes, int offset, int length) { PackDecoder decoder = PackDecoder.newInstance(bytes, offset, length); List<Long> list = decoder.getLongList(0); decoder.recycle(); return (list != null) ? list : new ArrayList<>(); } } 

    Encoding objects needs serialization/deserialization.

    Here recommend my serialization project: https://github.com/BillyWei01/Packable

    • For Android

    Comparing with common case, Android platform has SharePreferences API and support Kotlin.

    See: Android Case

    3. Benchmark

    • Data source: Collecting part of the key-value data of SharePreferences in the app , with hundreds of key-values. Because some key-values are accessed more and others accessed less in normally, I make a normally distributed sequence to test the accessing.
    • Comparison component: Sharepreferences/DataStore/MMKV.
    • Device: Huawei Horor 20s.

    Result:

    Write(ms) Read(ms)
    SharePreferences 1182 2
    DataStore 33277 2
    MMKV 29 10
    FastKV 19 1
    • SharePreferences use the apply mode. When use commit mode, it will be much slower.
    • DataStore writes data very slow.
    • MMKV read slower then SharePreferences/DataStore,but much faster in writing.
    • FastKV is the fastest both in writing or reading.

    Project link: https://github.com/BillyWei01/FastKV

    submitted by /u/9c2cu
    [link] [comments]

    What kind of information do you log in Crashlytics and Analytics?

    Posted: 27 Oct 2021 02:27 AM PDT

    I would like to log more information to Crashlytics and Analytics to monitor my apps, for example to help me reproduce crashes or see what functionalities are the most used.

    The truth is I have been thinking about it for a long time but have no idea how to get started. Technically it seems easy but I have no idea what information would be the most relevant.

    Maybe I can implement some "low level solution" like logging the label of every button the user click (along with the name of the screen) so I can easily follow the exact workflow they followed to reproduce a bug they encountered.

    How did you do it? Have you found good documentation on this topic?

    submitted by /u/CrisalDroid
    [link] [comments]

    How to use google_ml_kit with flutter for on device translation

    Posted: 27 Oct 2021 02:39 AM PDT

    Location Updates with BroadcastReceiver pitfall

    Posted: 26 Oct 2021 09:22 PM PDT

    Hey guys basic java/android question (inside a react native app)

    Posted: 27 Oct 2021 07:47 AM PDT

    So, on the react native side I press a button and it's supposed to send a request to my server (using java code, not javascript), and that server response should be sent back to the VS code javascript file.

    On button press, I execute these two functions in react native, from my custom module:

    <Button title="Send Request" onPress={()=>{ //sends the request to server CustomModule.sendVolleyRequest(); //gets the server response, as a string CustomModule.returnServerResponse((serverResponseString)=>{ //print string console.log(serverResponseString); }) }}> </Button> 

    And these are the two @ React Methods that I'm trying to execute. But the problem is on the very first time I press the button, the response string is null. This is how the module is setup:

    public class CustomModule extends ReactContextBaseJavaModule { private String responseString = null; //... //constructor //getName() //method that sends a simple generic request to the node.js server using Volley @ReactMethod public void sendVolleyRequest(){ String url = "http://my.ip.address:8080/payment/braintree/test"; Context context = getReactApplicationContext(); //get a request queue, from volley RequestQueue queue = Volley.newRequestQueue(context); //create a JSON object that will be sent to server JSONObject jsonObject = new JSONObject(); try{ jsonObject.put("Message", "Hello world" ); } catch (JSONException exception){ Log.d("error", "JSONExceptionThrown" ); } //execute the request, and store the response string which is above JsonObjectRequest jsonRequest = new JsonObjectRequest(Request.Method.POST, url, jsonObject, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { responseString = response.toString(); /** **/ } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.d("Trigger", "Volley error"); } } ); //execute the request queue.add(jsonRequest); } //this is supposed to return the response string to javascript @ReactMethod public void returnServerResponse(Callback callback){ callback.invoke(responseString); } } 

    What do you guys think the problem is? Is it because returnServerResponse() is executed synchronously, and therefore, will be null, because it doesn't wait for sendVolleyRequest()?

    Secondly, can anyone point me on how to write asynchronous methods, or any ideas how to resolve this problem? Not sure what to do. Thank you! Should I use threading here or something? I'm still a little new to Java.

    submitted by /u/ThisSoFrustrating
    [link] [comments]

    Android gestures

    Posted: 27 Oct 2021 07:25 AM PDT

    Hi everyone :-)

    I'd like to ask you if you know a good source for gesture overview in Android. I am still figuring out if it's up to he device brand (like Samsung or Xiaomi...) or it is just driven by Android itself.

    It's easy for IoS since there is this nice overview:

    https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/gestures/

    I am searching for something similar for Android.

    You have some advice? :)

    submitted by /u/awesome_alice
    [link] [comments]

    How can I start my animation (objectAnimator) with the modified values from a ValueAnimator? (JAVA / XML)

    Posted: 27 Oct 2021 04:21 AM PDT

    The changes are working perfectly if I test them with an Log.d, but I want to affect them on my animation (maybe with save them in the preferences?). Because my animation (animation2) starts, but with the standard values of the XML, not the "updated" / temporarily edited values (from pivotX).

    Please visit my question. I hope someone can help me. Thanks in advance!

    submitted by /u/4Serious20
    [link] [comments]

    My interview with Repeato about their Android no-code UI testing platform at Droidcon Berlin 2021.

    Posted: 27 Oct 2021 02:15 AM PDT

    Understanding android documentation

    Posted: 27 Oct 2021 01:15 AM PDT

    Hey guys I find it really tough to understand android official dicumentation.I dont find relevant code example most of the time on official documentation.Can someone guide me how shall I start with documentation so it would get much easier for me to understand most of the stuff on it to an extent that i can make my own code sample from the android documentation's site?

    submitted by /u/Da_____k
    [link] [comments]

    Google Play developer account got terminated because span multiple account registrations, can i transfer my apps to another account?

    Posted: 26 Oct 2021 07:35 PM PDT

    Hi everyone,

    I am an android developer, On 21th Oct 2021 my Google Play developer account got terminated because span multiple account registrations. It's because I'm logging in on the same device, and I read on several forums, they said that my account could not be recovered.

    My question is, can I restore my app and transfer it to another account? because I see in the email it's not an app suspend issue. And secondly, what about the remaining balance in your Google Pay account? will they pay it next month even though my account has been terminated?

    Thanks

    submitted by /u/vaingloryx
    [link] [comments]

    Gadget - A library to make analytics event tracking more easier and reliable

    Posted: 26 Oct 2021 09:25 AM PDT

    Inflate fragment inside InputMethodService

    Posted: 26 Oct 2021 02:39 PM PDT

    There is a way to inflate a fragment inside a input method service?

    Can we access, somehow, an instance of supporFragmentManager inside InputMethodService classes?

    submitted by /u/gusoliv3ira
    [link] [comments]

    input validation

    Posted: 26 Oct 2021 01:18 PM PDT

    what is the best/clean approach to implement input validation in android for multiple fields

    submitted by /u/abdalla_97
    [link] [comments]

    Can you guys help me with understanding contexts?

    Posted: 26 Oct 2021 12:45 PM PDT

    I'm pretty new to android dev. Java in general. I got volley working. And I'm trying to write this request, but I'm confused about what I should put for the context. Android seems to have a million different contexts. Then there's also react application context. Since this a react-native app and a custom module so I have it set up this way:

    public class CustomModule extends ReactContextBaseJavaModule { //constructors necessary to take in the react context CustomModule(ReactApplicationContext context){ super(context); } @NonNull @Override public String getName() { return "CustomModule"; } //method that sends a simple generic request to the node.js server using Volley @ReactMethod public void sendGenericRequest(){ Log.d("Send", "Inside custom module..."); //String url = "https://www.google.com"; //RequestQueue queue = Volley.newRequestQueue(this); System.out.println(this.getClass().toString()); } } 

    So which context would it be, and how would I find it? The this keyword doesn't work, it's just an error. This might refering to the CustomModule class itself I believe rather than something that subs or implements the context interface.

    Can anyone explain where this context operates from or is located? Instead, it seems like it's just floating out there some where in the aether.

    Any ideas?

    submitted by /u/ThisSoFrustrating
    [link] [comments]

    No comments:

    Post a Comment