I have an image which I want to post to my server with other parameters using Alamofire. I am using multipart method of Alamofire for uploading but not getting post and in console also not showing any errors.I had refer this question for implementing Uploading file with parameters using Alamofire . Here is my code:

let productImage:UIImage = itemImage.image!
let dataImage = UIImageJPEGRepresentation(productImage, 1.0)
let url = "Some URL "
let parameter = ["product_name": productName, "product_price": productPrice] 
let headers : HTTPHeaders = ["Content-Type": "application/json","Authorization" : "Some Token"]

Alamofire.upload(multipartFormData: {
            multipartFormData in

            multipartFormData.append(dataImage!, withName: "file", fileName: "file.jpg", mimeType: "image/png")
            for (key,value) in parameter {
                multipartFormData.append(value.data(using: .utf8)!, withName: key)
            }
        }, to: url,method: .post, headers: headers, encodingCompletion: { encodingResult in
            switch encodingResult {
            case .success(let upload,_,_):
                upload.responseJSON {[weak self] response in
                    print(response.result.value)
                }
                break
            case .failure(let encodingError):
                print("error: \(encodingError)")
                break
            }
        })

If anyone can solve my problem.Thank you.

I am building a master detail app. I have a sections view controller (VC) which is a child of master VC. Clicking on rows in the sections VC brings up different detail VCs where users complete required information. Once the information in a detail VC is completed I would like to have a checkmark display in the relevant section VC row. FYI selectedProject is a core data object.

I call a notification in the detail VC viewWillDisappear to refresh the sections VC.

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
    let detailCase: String = selectedProject!.section![indexPath.row]
    configureCell(cell, withSectionName: detailCase)
    print("location complete is \(selectedProject!.completeLocation)")
    print("electricity complete is \(selectedProject!.completeElectricity)"
    print(cell.textLabel!.text!)
    print(cell.accessoryType.rawValue)
    return cell
}

func configureCell(_ cell: UITableViewCell, withSectionName sectionName: String) {
        switch sectionName {
        case "Project Details" :
            cell.accessoryType = .checkmark
        case "Location" :
            if selectedProject?.completeLocation == true {
                cell.accessoryType = .checkmark
            }
        case "Electricity Use" :
            if selectedProject?.completeElectricity == true {
                cell.accessoryType = .checkmark
            }
        default :
            cell.accessoryType = .none
        }
        cell.textLabel!.text = sectionName
}

func refreshTable(notification: Notification) -> Void {
    print("Notification ran")
    self.tableView.reloadData()
}

Notification ran

location complete is true

electricity complete is true

Project Details

3

location complete is true

electricity complete is true

Location

3

location complete is true

electricity complete is true

Electricity Use

3

The 3's = .checkmark

So it appears cellForRowAt knows exactly what it should be doing but then the table is not readily displaying the checkmarks. Instead you either have to click back to the master VC then forward to the sections VC to get the checkmarks displaying, or you have to click different rows in the section VC and the checkmarks will randomly show up.

I've tried calling reloadData in dispatchqueue.main.async with no luck. I tried calling reloadData at different points in the process again without success. I've tried calling tableView.beginUpdates/.endUpdates and reloadSectionData, again without success to get the checkmarks to display.

If I programmatically prompt section VC viewWilDisappear and viewWillAppear in succession, the checkmarks will appear once a different row in sections VC is selected. it "seems" like reloadData() isn't prompting a complete reload of the tableView.

FYI accessory item is set to .none in the storyboard.

The shadow is appearing on top of the navigation bar. Is there anyway to move the shadow underneath the bar or add some code so it doesn't discolor the bar?

This is the code I use in my navigation controller:

override func viewDidLoad() 
    {

    var appblue = UIColor(red: 109/255, green: 208/255, blue:247/255, alpha: 1.0)
    self.navigationBar.barTintColor = appblue
    self.navigationBar.layer.masksToBounds = false
    self.navigationBar.layer.shadowColor = UIColor.black.cgColor
    self.navigationBar.layer.shadowOpacity = 0.7
    self.navigationBar.layer.shadowOffset = CGSize(width: 0, height: 2.0)
    self.navigationBar.layer.shadowRadius = 4

    }

and this is what it looks like:

enter image description here

When it should be this color:

enter image description here

Any suggestions?

When click on a select tag, I can only select the first option, if try to drag down it will reset to the default option anyway, BTW the webview framework I'm using works fine on other projects. Please see the demo video below, thanks!

Demo link: http://recordit.co/nxaQk1C0ML

I have an app which plays a lot of video files. It's been all good on every phone and tablet I've tested on. I just tested on an Acer Chromebook and the first few frames (maybe up to a 1/4 second) are being dropped on all video files, so the video appears to start just slightly beyond 0. Some of the videos have audio that starts immediately and so it's obvious to the user that the video is clipped at the start. I'm wondering if anyone else has seen this issue, maybe on a Chromebook or other device and if there is some simple way to deal with it?

There is absolutely nothing fancy about my code. I'm using VideoView, preload the video with setVideoURI(), then call videoView.start() on a button press.

Thanks!

I cannot find an answer to this question anywhere online, so the answer must be so simple that no one cared to ask it, and I simply don't know it.

Essentially, I want to add a horizontal line between every item in my recyclerView AND to the bottom of the RecyclerView. I have found a way to place a divider between every item in the RecyclerView, but not one at the end.

According to the documentation (found here: https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html#addItemDecoration(android.support.v7.widget.RecyclerView.ItemDecoration, int) )

putting a negative int into the addItemDecoration(RecyclerView.ItemDecoration decor, int index). should solve this problem, stating:

If this value is negative the decoration will be added at the end.

This is the constructor method for my custom RecyclerView:

public CustomRecyclerView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    setHasFixedSize(true);
    setLayoutManager(new LinearLayoutManager(context));
    decor = new HorizontalDividerItemDecoration.Builder(context).build();
    addItemDecoration(decor, -1);
}

As you can see, I am using a negative integer in addItemDecoration(), and I cannot figure out why it is not working the way it is supposed to.

Any help would be greatly appreciated!

Shadow style works fine for iOS but on Android only elevation works and I can't add style to it? So is there any way to add shadowOpacity, shadowColor, shadowOffset ... etc?

Why is logging in typically an async task? It doesn't really seem necessary to me. I'm not really sure why android studio generates an async task for logging in when you have it generate a login activity for you.

I was wondering how can I use eclipse to debug a multi-module google web tool + spring mvc project that is built with maven. I can debug the back end code but I am having difficulty debugging the gwt code. I am not able to use or setup super dev mode from inside eclipse. Can you please help by providing links or advice on how to do this ?

This is my code:

let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)
_ = Alamofire.download("http://www.sample.com/images/sample.png", to: destination)

let imageURL = URL(fileURLWithPath: dirPath).appendingPathComponent("sample.png")

if let image = UIImage(contentsOfFile: imageURL.path) {
    self.sampleImage.image = image
}

First time I ran this code, the image was nil; so I set a breakpoint on the download, stepped just past the download code, checked the directory on disk and the image has not been saved to file (which is why the image was nil). After all the code in the UIViewContoller class was ran, the file was successfully saved to disk, and the second time I navigated to the ViewController, the image loaded.

Is there any way to download the image, immediately save it to disk, then display the image right after?

I've tried putting the download code in viewWillAppear and the load from disk code in viewDidLoad. I also tried creating a method with a completion block and put the download code inside the completion block.

I have an application and am using GRDB.swift to query data from an sqlite pool.

I made the initial configuration pot when I do the SELECT to get the right column that I need the app crash.

func loadCity(){
        do {

            let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! as NSString
            let databasePath = documentsPath.appendingPathComponent("data.sqlite")
            let dbQueue = try DatabaseQueue(path: databasePath)

            do {
                dbQueue.inDatabase { db in
                    //app crash here:
                    let poiTitles = String.fetchOne(db, "SELECT MUNICIPIO FROM municipios")
                    print(poiTitles!)
                }
            }

        } catch {
            print("failed")
        }
    }

This is my sqlite data: This is my sqlite data:

I believe my SELECT is right. What can I be doing wrong?

This is the error: This is the error

I am getting this error Value <,br of type java.lang.String cannot be converted to JSONObject at org.json.JSON.typeMismatch(JSON.java:111)

W/System.err: at org.json.JSONObject.(JSONObject.java:160) W/System.err: at org.json.JSONObject.(JSONObject.java:173) W/System.err: at com.kjy.loginregister.Register$1.onResponse(Register.java:50) W/System.err: at com.kjy.loginregister.Register$1.onResponse(Register.java:46)

here is my code:

public void onResponse(String response) {
                    try {
                        JSONObject js = new JSONObject(response);
                        boolean success = js.getBoolean("success");
                        if(success){
                            Intent intent = new Intent(Register.this, Login.class);
                            Register.this.startActivity(intent);
                        }else{
                            AlertDialog.Builder ab = new AlertDialog.Builder(Register.this);
                            ab.setMessage("Registration Failed")
                                    .setNegativeButton("Retry",null)
                                    .create()
                                    .show();
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }

Here is my Php:

 <?php
$conn = mysqli_connect('dssdf', 'sdff','sdf','dsfff');

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}else{
    $usu = $_POST["usu"];
    $pass = $_POST["pass"];
    $sql = "INSERT INTO usuario (usario, pass)
    VALUES( '$usu', '$pass')");
if ($conn->query($sql) === TRUE) {

    $msg="success";
} else {
     $msg = "unsuccessful"; 
 }
 print(json_encode(array("success" => $msg)));
?>

I have installed openvpn on my server and I use a client to connect to my VPN , so before deploy it I want to know if we can connect without using the official client, so add it normally from Android settings What are the settings to put in the "add VPN" such as Type (PPTP, L2TP, IPSec, ...) and how to log in with username/pass intsead of ovpn file ?

Thanks !

I do not want to have multi checked radio buttons with TableLayout.I had many searches and found a java class to do it. but it doesn't work. I want allow just one radio button be check,no more.only one of my radio buttons be check and other be uncheck if they was checked.

my layout:

<RadioGroup
                        android:id="@+id/radio_group_flight_type_raw1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingTop="@dimen/act_flight_objects_height_padding">

                        <ir.safarbazha.safarbazha.Core.adapter.FlightRadioButtonListener
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content">

                        <TableRow
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content">

                            <RadioButton
                                android:id="@+id/RadioButtonOneWayFlightType"
                                android:layout_width="0dp"
                                android:layout_height="@dimen/act_flight_objects_height"
                                android:layout_weight="0.5"
                                android:text="@string/radio_btn_one_way"
                                android:textSize="@dimen/big_size"/>

                            <RadioButton
                                android:id="@+id/RadioButtonRoundTripFlightType"
                                android:layout_width="0dp"
                                android:layout_height="@dimen/act_flight_objects_height"
                                android:layout_weight="0.5"
                                android:checked="true"
                                android:text="@string/radio_btn_round_trip"
                                android:textSize="@dimen/big_size"/>

                        </TableRow>


                        <TableRow
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content">

                            <RadioButton
                                android:id="@+id/RadioButtonLastSecondFlightType"
                                android:layout_width="0dp"
                                android:layout_height="@dimen/act_flight_objects_height"
                                android:layout_weight="0.5"
                                android:text="@string/radio_btn_last_second"
                                android:textSize="@dimen/big_size"/>

                            <RadioButton
                                android:id="@+id/RadioButtonCalendarRouteFlightType"
                                android:layout_width="0dp"
                                android:layout_height="@dimen/act_flight_objects_height"
                                android:layout_weight="0.5"
                                android:text="@string/radio_btn_calendar_route"
                                android:textSize="@dimen/big_size"/>

                        </TableRow>
                        </ir.safarbazha.safarbazha.Core.adapter.FlightRadioButtonListener>

                    </RadioGroup>

my java class:

package ir.safarbazha.safarbazha.Core.adapter;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RadioButton;
import android.widget.TableLayout;
import android.widget.TableRow;

/**
 * Created by MyPC on 3/2/2017.
 */

public class FlightRadioButtonListener extends TableLayout implements View.OnClickListener {

    private RadioButton mBtnCurrentRadio;

    public FlightRadioButtonListener(Context context) {
        super(context);
    }

    public FlightRadioButtonListener(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void onClick(View v) {
        final RadioButton mBtnRadio = (RadioButton) v;

        // select only one radio button at any given time
        if (mBtnCurrentRadio != null) {
            mBtnCurrentRadio.setChecked(false);
        }
        mBtnRadio.setChecked(true);
        mBtnCurrentRadio = mBtnRadio;
    }

    @Override
    public void addView(View child, int index,
                        android.view.ViewGroup.LayoutParams params) {
        super.addView(child, index, params);
        setChildrenOnClickListener((TableRow) child);
    }

    @Override
    public void addView(View child, android.view.ViewGroup.LayoutParams params) {
        super.addView(child, params);
        setChildrenOnClickListener((TableRow) child);
    }

    private void setChildrenOnClickListener(TableRow tr) {
        final int c = tr.getChildCount();
        for (int i = 0; i < c; i++) {
            final View v = tr.getChildAt(i);
            if (v instanceof RadioButton) {
                v.setOnClickListener(this);
            }
        }
    }

}

I updated my android-studio to latest stable version i.e. 'Android Studio 2.3' and also the gradle to 2.3.0.

Now, when I am trying to generate a signed apk of my app's release build, this "extra" thing (Signature versions:) is getting shown in the last:

enter image description here

I clicked on 'Signature Help' and this page got opened.

I followed the doc and made changes to my build.gradle file like this:

apply plugin: 'com.android.application'

//Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'

android {
    signingConfigs {
        config {
            keyAlias 'xxxxxx'
            keyPassword 'xxxxxx'
            storeFile file('/Users/xxxxx)
            storePassword 'xxxxxx'
            v2SigningEnabled false
        }
    }
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    lintOptions {
        abortOnError false
    }
    defaultConfig {
        applicationId "com.xxxxx.xxx"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        debug {
            signingConfig signingConfigs.config
        }
    }
    repositories {
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
        maven { url 'https://maven.fabric.io/public' }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.mikepenz:fastadapter:1.8.2@aar') {
        transitive = true
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
        transitive = true;
    }
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:design:25.0.0'
    compile 'com.android.support:cardview-v7:25.0.0'
    compile 'com.android.support:recyclerview-v7:25.0.0'
    compile 'com.google.android.gms:play-services:10.2.0'
    compile 'com.google.android.gms:play-services-location:10.2.0'
    compile 'com.google.firebase:firebase-auth:10.2.0'
    compile 'com.android.support:support-v4:25.0.0'
    compile 'com.google.firebase:firebase-database:10.2.0'
    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

and tried to generate the signed apk again but still this "extra" thing is getting shown.

What should I do now to sign apk "with only the traditional scheme"?

I have a TextView that I'm dynamically adding text to via code. This text view is intended to act as a way to view diagnostics in my application in real time.

I need the logger to act as a circular buffer of lines of text, so that when it reaches the maximum number of lines, old lines get pushed out for newer lines of text. This must also work properly with line wrapping (wrapped parts of a line should not count towards the maximum number of lines).

At the moment I don't have the slightest idea how to code this. I did some googling and I found a few approaches that require manually parsing the text view's buffer, but that seems like it will have performance issues when you're dealing with hundreds of lines. Ideally I'd like to maintain a circular list of some sort, where I add lines of text, and use some sort of adapter with TextView so that it reads and concatenates lines of text from that list and efficiently updates its text view when elements are added to that container.

I'm not sure if such a mechanism exists in Android, but I'm posting here for any ideas with efficiency in mind since I need to be able to handle anywhere from 5000 to 10000 lines of text in this text view.

Note that my minimum supported API level is 15.

I was not able to sync android project that i imported from outside of android studio. Anyone has a solution to fix bottom issue?

Error:Module 'androidsupportv7appcompat': platform 'Google Inc.:Google APIs:19' not found.

my goals is to add some text info in video output file (e. g. date/time, user id etc.). I am checked some reference how to do this for camera API but can't found information how to do this for camera2 API. Can anyone help me? This is what i found for camera API

This is what i found for camera API

I have two images that can`t be separated. It's the ship and the flame, which will appear on the screen under certain conditions. In short, the flame and the ship has to be different images, so I could hide the flame at the right time, but the camera needs to follow the ship and flame at the same time. The option of placing them in one group not working.

I use pespective.lua camera.

I just can't figure out how to install Android SDK to create new Android project on IntelliJ properly.

While trying to make a new project, red bold warning appears: Your Android SDK is missing, out of date, or missing templates. Please ensure you are using SDK version 24.0.2 or later.

The problem is, I don't really know how to fix it. Where could I eventually find accurate SDK and how to fix that? Thanks in advance!

I am using Azure Mobile Apps authentication with Facebook in my app. The log in and log out is fine. I can log in with my Facebook but I am having trouble getting additional Facebook details like my profile name and picture. How can I access it with android code?