#StackBounty: #android #caching #mvp MVP Adapter Data Cache

Bounty: 50

I’m developing project following MVP architecture. Usually, when I use recyclerView, my presenter controls Adapter data. But now I need to make recycler adapter with data from cache (or something like cache), recycler’s size dosen’t depends on cache size, so I make cache via HashMap where the key is – position of recycler, if there is an item in map then the data shows, else empty row with something like “add events” btn. And I can’t realize where the place for that cache in such structure – Model (Dao or something like CacheManager) or in Adapter.

The cache idea is following: I have some types of events which store in database, every event modifying changes it in db – so the cache has to be updated either.

The main questions are: where to keep this cache and load it to adapter, how can i keep it sync with database changes.

P.S. Also I tries to use RX, so if it can be solved with it – would be very interesting to try.

P.P.S If it the Repository pattern is the way to solve – welcome. Read about it sometime ago.


Get this bounty!!!

#StackBounty: #android #notifications #remote-input How to specify min and/or max length in RemoteInput

Bounty: 50

I use RemoteInput in my Android N notifications.

I want to set a min and max text length limit for the input.

Google Hangouts got this (i.e. the send button enables when the user entered at least 1 character). Anyone know how this can be done? I’ve tried to check the Android docs but no luck.


Get this bounty!!!

#StackBounty: #android Register my app as camera app in Android

Bounty: 50

I got help from android: how to register my app as "camera app" but still it’s not properly working

I have tried with my Contact App to add photo to my existing saved Contact, whom URI will be generated like below

content://com.google.android.contacts.files/my_cache/ContactPhoto-IMG_20170412_123034.jpg

but I can not access to that Contact app’s directory, so I can not save photo over that URI and if I do I will get FIleNotFoundException,

Uri saveUri = (Uri) getIntent().getExtras().getParcelable(MediaStore.EXTRA_OUTPUT);

if (saveUri != null)
{
    // Save the bitmap to the specified URI (use a try/catch block)
    outputStream = getContentResolver().openOutputStream(saveUri); <-----File Not Found Exception 

but same functionality is achieved by default Camera App

will anybody has suggestion how to resolve this issue

Thanks,


Get this bounty!!!

#StackBounty: #android #aes routines:EVP_DecryptFinal_ex:wrong final block length in android

Bounty: 200

Actually i work in a app and have a problem with decrypt AES

i have a error in this line byte[] results = cipher.doFinal(Base64.encode(text.getBytes("UTF-8"), Base64.DEFAULT));

error : error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wr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rCPiCaBn6g==;

        try {
            Decrypt(data,key);
        } catch (Exception e) {
            e.printStackTrace();
        }

Method

String Decrypt(String text, String key) throws Exception {
    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    byte[] keyBytes = Base64.decode(key.getBytes(), Base64.DEFAULT);
    SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
    byte[] b = new byte[keySpec.getEncoded().length];
    System.arraycopy(keySpec.getEncoded(), 0, b, 0, b.length);
    IvParameterSpec ivSpec = new IvParameterSpec(b);
    cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
    byte[] results = cipher.doFinal(Base64.encode(text.getBytes("UTF-8"), Base64.DEFAULT));
    String  decoded = new String(cipher.doFinal(results), "UTF-8");
    return decoded;
}


Get this bounty!!!

#StackBounty: #android #ios #bonjour #multipeer-connectivity #dns-sd Android & iOS dns-sd: how to do a cross platform service disco…

Bounty: 50

On Android I’m doing this way to create a service broadcast with a simple attacched map as info

HashMap<String, String> record = new HashMap<>();
record.put("info, "my android info");    
WifiP2pDnsSdServiceInfo serviceInfo = WifiP2pDnsSdServiceInfo
        .newInstance("_myservice", "_tcp", record);
WifiP2pManager manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
Channel channel = manager.initialize(this, this.getMainLooper(), null);
manager.addLocalService(channel, serviceInfo, null);

to retrieve another signal

manager.setDnsSdResponseListeners(channel, this, this);

@Override
public void onDnsSdTxtRecordAvailable(String fullDomainName, Map<String, String> txtRecordMap, WifiP2pDevice srcDevice)

On iOS it’s the same service name and map of info

MCPeerID* _myPeerId=[[MCPeerID alloc] initWithDisplayName:@"my ios peer"];
NSDictionary* _serviceInfo=@{@"info": @"my ios info"};

MCNearbyServiceAdvertiser* _serviceAdvertiser = [[MCNearbyServiceAdvertiser alloc] 
         initWithPeer:_myPeerId discoveryInfo:_serviceInfo serviceType:@"myservice"];
_serviceAdvertiser.delegate=advertiseDelegate;

MCNearbyServiceBrowser* _serviceBrowser=[[MCNearbyServiceBrowser alloc] 
      initWithPeer:_myPeerId serviceType:@"myservice"];
_serviceBrowser.delegate=browserDelegate;

[_serviceAdvertiser startAdvertisingPeer];
[_serviceBrowser startBrowsingForPeers];

and the delegates

-(void)browser:(MCNearbyServiceBrowser *)browser lostPeer:(MCPeerID *)peerID
-(void)browser:(MCNearbyServiceBrowser *)browser foundPeer:(MCPeerID *)peerID withDiscoveryInfo:(NSDictionary<NSString *,NSString *> *)info

An Android device can see only another Android device, likewise between iOS devices. However, the two families can’t see each other.
I’d like to have them seen by other devices regardless of the operating system.


Get this bounty!!!

#StackBounty: #c# #android #xamarin #mono #xamarin.android How to stop a process from System.Diagnostics.Process and get the statistics…

Bounty: 100

I’m using this code but when i stop the process it not get the ping statistics :

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "ping";
p.StartInfo.Arguments = "-c " + count + " -i " + interval + " -s " + buffer + " -W " + timeout + " " + address;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;

string readData = "";

DateTime dt = DateTime.Now.AddSeconds(5);
if (p.Start())
{
    Scanner scanner = new Scanner(p.StandardOutput.BaseStream);

    while (scanner.HasNextLine)
    {
        readData =  scanner.NextLine().ToString();
        Console.WriteLine(readData.ToString());

        if (!string.IsNullOrEmpty(readData) && !readData.StartsWith("---"))
        {
            Match M = Regex.Match(readData, @"^[d]+ bytes from ([^:]+): [^ ]+ ttl=([d]+) time=([^ ]+) ms");

            if (M != null && M.Success)
            {
                string IP = M.Groups[1].Value;
                string TTL = M.Groups[2].Value;
                string timeStr = M.Groups[3].Value;

                Console.WriteLine(String.Format("Ping to {0} took {2} ms with a ttl of {1}", IP, TTL, timeStr));
                // Parsing the timeStr will work the same way as above
               if(dt > DateTime.Now)
               {
                   p.StandartInput.Write("x3");
                }
            }
            else
            {
                Match M1 = Regex.Match(readData, @"^rtt [^0-9]*([d][^/]+)/([^/]+)/([^/]+)/([^ ]+) ms$");

                if (M1 != null && M1.Success)
                {
                    float avgPingTime = 0;
                    float maxPingTime = 0;
                    float minPingTime = 0;

                    string minPingString = M1.Groups[1].Value;
                    string avgPingString = M1.Groups[2].Value;
                    string maxPingString = M1.Groups[3].Value;

                    // Now parse that value
                    float.TryParse(minPingString, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out minPingTime);
                    float.TryParse(avgPingString, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out avgPingTime);
                    float.TryParse(maxPingString, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out maxPingTime);

                    Console.WriteLine(String.Format("Min Time : {0} , AVG {2} ms, Max Time {1}", minPingTime, maxPingTime, avgPingTime));
                }
            }
        }
    }
}

Without using

if(dt > DateTime.Now)
{
     p.StandartInput.Write("x3");
}

the result display like this :

64 bytes from 8.8.8.8: icmp_req=1 ttl=46 time=13.9 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=46 time=13.9 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=46 time=13.9 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 3016ms
rtt min/avg/max/mdev = 13.910/13.926/13.951/0.010 ms

but if I stop the ping using p.StandartInput.Write("x3"); it never goes to the statistics part it hangs at sequence 1 and dont continue reading , how to show the statistics after stoping the ping process ?

in other words my problem is when the user want to stop the ping it should display the statistics for the certain time that it was used to ping…

UPDATE

I have implemented p.StandartInput.Write("/x3"); and it interrupts the ping process but it does not display the statistics and just hangs there.


Get this bounty!!!

#StackBounty: #android TimePicker bug. Any workaround?

Bounty: 100

I found some problem for TimePicker widget. After user change time in widget setHour and setMinute methods not works.

public class MainActivity extends AppCompatActivity {

    private Button mButton;
    private TimePicker mTimePicker;

    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mButton = (Button) findViewById(R.id.reset);
        mTimePicker = (TimePicker) findViewById(R.id.timePicker);

        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Calendar cal = Calendar.getInstance();
                int hour = cal.get(Calendar.HOUR_OF_DAY);
                int minute = cal.get(Calendar.MINUTE);

                mTimePicker.setHour(hour);
                mTimePicker.setMinute(minute);

                Log.v(TAG, "onClick: " + hour + "=>" + mTimePicker.getHour());
                Log.v(TAG, "onClick: " + minute + "=>" + mTimePicker.getMinute());
            }
        });
    }
}

Step for reproduce:

  1. Run app (my time: 13:21)
  2. Change time on the Widget (21:21)
  3. Tap on the Reset button

Result:time not reset to 13:21

Log:

03-30 13:18:05.765 30923-30923/ru.neverdark.timepickerproblem
V/MainActivity: onClick: 13=>21 03-30 13:18:05.765
30923-30923/ru.neverdark.timepickerproblem V/MainActivity: onClick:
18=>18

Any workaround for this problem?

Same bug I found in Issue Tracker: https://code.google.com/p/android/issues/detail?id=208180 but in SDK25 not fixed…

Demo project on the github: https://github.com/yankovskiy/TimePickerProblem


Get this bounty!!!

#StackBounty: #java #android #android-activity #barcode-scanner Strange issue with intent startActivity causing my scanner to not work …

Bounty: 50

So, after I finish my scanner activity with

      btn_take_photo.setOnClickListener(new FloatingActionButton.OnClickListener() {
        @Override
        public void onClick(View view) {
            String carde = cardnumberbox.getText().toString().trim();
            if (carde.matches("")) {
                Toast.makeText(getApplicationContext(), getString(R.string.Skan_Udfyld_Kort_Nummer), Toast.LENGTH_SHORT).show();
                cardnumberbox.requestFocus();
                return;
            }
            Intent i = new Intent(ScanActivity.this, CameraActivity.class);
            i.putExtra("EXTRA_SESSION_ID", carde);
            startActivity(i);

        }
    });

to go to my cam activity so I can take some pictures and go back with

    public void btn_aprove2(View view) {
    Intent i = new Intent(CameraActivity.this, ScanActivity.class);
    String counts = count.getText().toString().trim();
    i.putExtra("EXTRA_SESSION_IDs", counts);
    String carde = cardnumberbox2.getText().toString().trim();
    i.putExtra("EXTRA_SESSION_ID", carde);
    startActivity(i);
    finish();

to the scanneractivity again. My scanner does not work properly
but if I then press the back button it does go back to the scanneractivity again instead of my menu so it seems like the scanneractivity is running twice and only 1 of them are functional but is here where it confuses me

cause if do not press the btn_aprove2 button and just use the back button instead
i gets the exact same issue but here my scanneractivity is not runned twice as when i press the back button it just takes me back to the menu

a video of the issue

by removing my screen orientation from the manifest (so i can rotate it)
my scanner do now work but only if i first rotate to landscape and rotate it back to potrait

I am totally lost on how to get this to work.

on github with api demo and documentation in the wiki and with thoose classes that are being used


Get this bounty!!!

#StackBounty: #tls #android #proxy #tools Nogotofail usage android pentesting

Bounty: 50

I was looking at the google tool: Nogotofail https://github.com/google/nogotofail

I used their examples to set it up and this works for the examples with proxychains.

But now I want to use it with my android device or android emulator (SDK or Genymotion). But this is where I just do not understand what I have to do.

I tried:
– Installing their “App” but this just crashes on my device or gives 2 options “SSL/TLS” and “HTTP” in an emulator and doesn’t do anything
– Just proxying all traffic to my machine on 8443, this gives a lot of bad handshake errors in nogotofail
– Proxying through Burp to nogotofail, which gives the same bad handshake errors.

From google’s documentation I understand that it should work on a router or VPN. But I don’t understand how to get that to work via my normal computer, and why it would not work by just proxying (like Burp works).

I think I am missing some base level understanding of this problem, but the documentation doesn’t help me with this.


Get this bounty!!!

#StackBounty: #android #retrofit #multipart is it possible to pass a single item as multipart using retrofit?

Bounty: 100

 @Multipart
@POST("/api/add-deal/")
public void addDeal(@Body Deal deal, @Part("image")TypedFile image,Callback<Response> callback);

I want to send only the image as multipart and the rest as is.Is there any possible way ? Even I tried to add TypedFile inside my Deal model but unable to annotate with @part


Get this bounty!!!