I have RecyclerView with custom adapter, using SortedList function I wanted to sort all items base on two TextView data, I found this Link for doing it and this how I used it on my code.

public class PageOnline extends Fragment {

    FrameLayout frame_img;
    LinearLayoutManager linearLayoutManager;
    RecyclerView recyclerView;
    static PageOnlineAdapter pageOnlineAdapter;
    List<DataListOnline> dataList;
    DataListOnline a;

    public PageOnline(){}

    public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        View view = inflater.inflate(R.layout.page_online, container, false);
        frame_img = (FrameLayout) view.findViewById(R.id.frame_img);
        linearLayoutManager = new LinearLayoutManager(getActivity().getBaseContext());
        recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this); //I'am using eventbus library

        dataList = new ArrayList<>();

        pageOnlineAdapter = new PageOnlineAdapter(getActivity().getBaseContext(), dataList, PageOnline.this);
        recyclerView.setItemAnimator(new DefaultItemAnimator());

        new DbHelper(getActivity().getBaseContext()).getAllData(); //Get all Items from Database when this Tab is selected or first time open
        return view;

    //This will be called when new Item is added, 
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(DataListOnline data) {
        if (recyclerView.getVisibility() == View.GONE) {
        a = new DataListOnline(data.getData1(), data.getData2(), data.getData3());

My custom adapter and where sorting Item is done

public class PageOnlineAdapter extends RecyclerView.Adapter<PageOnlineAdapter.TheViewHolder>{

    private Context mContext;
    private SortedList<DataListOnline> dataLists;
    private PageOnline pageOnline;

    public PageOnlineAdapter(Context context, List<DataListOnline> dataLists, PageOnline pageOnline){
        this.mContext = context;
        this.dataLists = new SortedList<>(DataListOnline.class, new DataListCallBack());
        this.pageOnline = pageOnline;

    public void addData(DataListOnline datas) {

    public void removeData(DataListOnline datas) {

    public void removeDatalist() {

    public class TheViewHolder extends RecyclerView.ViewHolder {
        TextView data1, data2, data3;
        public TheViewHolder(View itemView) {
            //...Initialize Textview

    public PageOnlineAdapter.TheViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.page_online_recyclerview_item, parent, false);
        return new TheViewHolder(itemView);

    public void onBindViewHolder(final PageOnlineAdapter.TheViewHolder holder, int position) {
        final DataListOnline dataList = dataLists.get(position);

    public int getItemCount() {
        return dataLists.size();

     * Implementation of callback for getting updates on person list changes.
    private class DataListCallBack extends SortedList.Callback<DataListOnline> {

        public int compare(DataListOnline o1, DataListOnline o2) {
            String dd1 = o1.getData1();
            String dd2 = o2.getData2();
            int diff = Integer.parseInt(dd1) - Integer.parseInt(dd2);
            return (diff == 0) ? o1.getData2().compareTo(o2.getData2()) : diff;

        public void onInserted(int position, int count) {

        public void onRemoved(int position, int count) {

        public void onMoved(int fromPosition, int toPosition) {


        public void onChanged(int position, int count) {


        public boolean areContentsTheSame(DataListOnline oldItem, DataListOnline newItem) {
            return false;

        public boolean areItemsTheSame(DataListOnline item1, DataListOnline item2) {
            return false;

DataListOnline class for Set and Get data

public class DataListOnline {

    private String data1, data2, data3;

    public DataListOnline(String data1, String data2, String data3){
        this.data1 = data1;
        this.data2 = data2;
        this.data3 = data3;

    public String getData1(){
        return data1;
    public String getData2(){
        return data2;
    public String getData3(){
        return data3;

This is how I populate Item from my database helper

public void getAllData(){
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor c = null;
            /.... Query
                while(c.isAfterLast() == false){
                    String data1 = c.getString(c.getColumnIndex(DATA1));
                    String data2 = c.getString(c.getColumnIndex(DATA2));
                    String data3 = c.getString(c.getColumnIndex(DATA3));

                    EventBus.getDefault().post(new DataListOnline(data1, data2, data3)); //Update EventBus to Addnew Item
        }catch (Exception e){
            Log.e(TAGS,"Failed to Get DATA => " + e.toString());
        }finally {

If I want to add new Item I just need to call this EventBus function

EventBus.getDefault().post(new DataListOnline("data value", "data value", "data value")); //Update EventBus to Addnew Item

It's working, but it's making a duplicate item at the second time I added a new Item(e.g. I added new 1 Item, at first it will be add once, but after adding another 1 Item it will become 3 items now), I can't figure it out why, this is the first time I've used SortedList function.

Very strange issue. I made a little flask app that lets me traverse the music folder on my server and zip + download any folder with music files in it.

Its very simple:

Creates a BytesIO object, opens this as a zipfile, and places each file inside the folder I want to download into the zipfile. Then via flask, just returns the file using send_file.

It works great on my computer (Linux) but for some reason, when I try to download it on my Android device (Google Pixel, Android 7.1), it always stops at about 64MB (I always end up with a corrupted/incomplete zip file).

When I was creating the little flask app, it worked great running it on host and navigating to it on my Android via the local network. Downloaded the full files flawlessly. When I deployed the app to my apache2 server, this strange behavior started. Any clue what the issue might be? No errors or anything show up in my apache logs.

Im creating a basic application, in android studio. The code seems to be okay. However, when I run it in Emulator the app doesn't work. Please help me determine what I am missing. CODE :package com.example.claudia.myapplication;

    import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends ActionBarActivity {

@Override// Calculating Body mass index
protected void onCreate(Bundle savedInstanceState) {
    final Button button_Calc = (Button) findViewById(R.id.button_Calc);
    final EditText Field_Weight = (EditText)      findViewById(R.id.Field_Weight);
    final EditText Field_Height = (EditText) findViewById(R.id.Field_Height);
    final TextView View_Result = (TextView) findViewById(R.id.View_Results);
    final TextView View_Msg = (TextView) findViewById(R.id.View_Msg);

    button_Calc.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            double weight;
            double height;
            double bmi;
            String msg = "";

            if (Field_Height.getText().toString().equals("") || Field_Weight.getText().toString().equals("")) {
                Toast.makeText(getApplicationContext(), "No Valid Values!", Toast.LENGTH_LONG).show();

                weight = Double.parseDouble(Field_Weight.getText().toString());
                height = Double.parseDouble(Field_Height.getText().toString());

                bmi = height * height;
                bmi = weight / bmi;


                if (bmi < 18.5) {
                    msg = "Client is Under Weight :(";
                } else if (bmi > 18.5 && bmi < 25) {
                    msg = "Normal :)";
                } else if (bmi > 25) {
                    msg = "Client is Overweight";



    // Calculating Calories in and out
        final Button Cal_calc = (Button) findViewById(R.id.Cal_calc);
        final EditText field_cal = (EditText) findViewById(R.id.field_Cal);
        final EditText field_burn = (EditText) findViewById(R.id.field_burn);
        final TextView View_calRes = (TextView) findViewById(R.id.View_calRes);
        final TextView View_calMsg = (TextView) findViewById(R.id.view_calMsg);

        Cal_calc.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                double calories;
                double burn;
                double CaloricTotal;
                String calMsg = "";

                if (field_cal.getText().toString().equals("") || field_burn.getText().toString().equals("")) {
                    Toast.makeText(getApplicationContext(), "No Valid Values!", Toast.LENGTH_LONG).show();

                    calories = Double.parseDouble(field_cal.getText().toString());
                    burn = Double.parseDouble(field_burn.getText().toString());

                    CaloricTotal = calories * calories;
                    CaloricTotal = burn / CaloricTotal;


                    if (CaloricTotal < 1500) {
                        calMsg = "Client Needs to consume more Calories :(";
                    } else if (CaloricTotal > 1500 && CaloricTotal < 2000) {
                        calMsg = "Client is Normal :)";
                    } else if (CaloricTotal > 2000) {
                        calMsg = "Client Needs to consume less calories";



RUN Error::

11/01 22:57:40: Launching app $ adb shell am start -n "com.example.claudia.myapplication/com.example.claudia.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Connected to process 3591 on device emulator-5554 I/art: Not late-enabling -Xcheck:jni (already on) W/art: Unexpected CPU variant for X86 using defaults: x86 W/System: ClassLoader referenced unknown path: /data/app/com.example.claudia.myapplication-2/lib/x86 I/InstantRun: Instant Run Runtime started. Android package is com.example.claudia.myapplication, real application class is null.

          [ 11-01 22:53:09.592  1515: 1538 D/         ]
          HostConnection::get() New Host Connection established 0x95618500, tid 1538

W/System: ClassLoader referenced unknown path: /data/app/com.example.claudia.myapplication-2/lib/x86 W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.claudia.myapplication, PID: 3591 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.claudia.myapplication/com.example.claudia.myapplication.MainActivity}: java.lang.IllegalStateException: Already attached at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: java.lang.IllegalStateException: Already attached at android.support.v4.app.FragmentManagerImpl.attachController(FragmentManager.java:2132) at android.support.v4.app.FragmentController.attachHost(FragmentController.java:104) at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:315) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:85) at com.example.claudia.myapplication.MainActivity.onCreate(MainActivity.java:63) at android.app.Activity.performCreate(Activity.java:6664) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)  at android.app.ActivityThread.-wrap12(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6077)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)  Application terminated.

As Sync Adapters does is as soon as the data is changed the UI gets updated and it requires content providers to be created and Firebase does the same thing when DataBase is created on it

I'm using this TTS library (https://github.com/happyalu/Flite-TTS-Engine-for-Android) for my TTS project. I got this kind of issue after i ran this command in terminal.

/Applications/android-ndk-r8e/ndk-build NDK_PROJECT_PATH=/Users/ZERO/Documents/Github/Flite-TTS-Engine-for-Android-1 NDK_APPLICATION_MK=/Users/ZERO/Documents/Github/Flite-TTS-Engine-for-Android-1/app/jni/Application.mk

Error message

Compile++ thumb  : ttsflite <= edu_cmu_cs_speech_tts_flite_service.cc
make: /Applications/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++: No such file or directory
make: *** [/Users/ZERO/Documents/Github/Flite-TTS-Engine-for-Android-1/obj/local/armeabi/objs/ttsflite/edu_cmu_cs_speech_tts_flite_service.o] Error 1

Please advice. Thank you.

I have a RecyclerView list with CardViews. I added the following code below to launch an activity (ActActivity) that allows the user to edit the CardView. The setEnabled(false) code is used to keep multiple instances of the activity from opening if the user clicks multiple times in rapid succession on the CardView. I only want one instance of the activity to be open at one time so that the user is only editing the single CardView that they clicked on.

My problem is that when I add the onResume() section to re-set setEnabled() to "true" the app crashes. When I remove the onResume() section then the setEnabled(false) code works correctly by not allowing multiple instances of the activity to open, but the problem is that any doubleclicks on the CardView disable a future single-click to correctly launch the ActActivity.

What am I missing here?


public class MainActivity extends AppCompatActivity implements
    RecyclerItemClickListener {
public void onItemClick(int position, View view) {
    CardView c = (CardView) view;
    ActActivity.start(this, contactListAdapter.getItem(position));

protected void onResume() {

    CardView cardView1 = (CardView) findViewById(R.id.singlecard_view1);

xml file:

    android:longClickable="true"  >

Logcat output does not like the "cardView1.setEnabled(true)" line:

11-01 23:22:54.814 1399-1399/com.example.v50 E/AndroidRuntime: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to resume activity {com.example.v50/com.v050.MainActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2575) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2603) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2089) at android.app.ActivityThread.access$600(ActivityThread.java:130) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4745) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.v050.MainActivity.onResume(MainActivity.java:279) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1184) at android.app.Activity.performResume(Activity.java:5082) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2565) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2603)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2089)  at android.app.ActivityThread.access$600(ActivityThread.java:130)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:137)  at android.app.ActivityThread.main(ActivityThread.java:4745)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)  at dalvik.system.NativeStart.main(Native Method) 

i would like to ask if there is a way to put extras or bundle when you call finish() method.

for example just like calling an activity u can do this:

Intent intent = new Intent(view.getContext(), AddListing.class);
                intent.putExtra("user_id", userID);

is it possible to use it in finish()?


I have a view with circle subview on one corner of the view. I defined the circle's position by autolayout.

I need to rotate and resize the base view.

The problem is that if I rotate and then resize the view, position of the circle won't be where I expect it to be.

How do I keep layout in such a situation?

No resize or rotaion.

enter image description here

After rotation and resize

enter image description here

import UIKit

class ExampleController: UIViewController {

// UI Appearance

private let buttonWidth: CGFloat = 40
private var themeColor: UIColor = UIColor.magentaColor()

// Resizing and rotating view

let myView: UIView = {
    let v = UIView()
    v.layer.borderWidth = 1
    v.layer.borderColor = UIColor.magentaColor().CGColor

    v.frame = CGRectMake(100, 150, 150, 225)

    return v

lazy var cornerButton: UIView = {
    let b = UIView()

    b.layer.cornerRadius = self.buttonWidth / 2
    b.layer.borderWidth  = 1
    b.layer.borderColor  = self.themeColor.CGColor

    return b

// Control 

@IBOutlet weak var angleSlider: UISlider!
@IBOutlet weak var widthSlider: UISlider!

override func viewDidLoad() {


func setupSubviews() {

    // Angle Slider
    angleSlider.minimumValue = 0
    angleSlider.maximumValue = 360
    angleSlider.value        = 0

    // Width Slider
    widthSlider.maximumValue = Float(view!.frame.width)
    widthSlider.value        = Float(myView.frame.width)

    // Corner Button
    myView.addSubview( cornerButton )
    myView.addConstraintsWithFormat("H:[v0(\(buttonWidth))]", views: cornerButton) // Use extension to set width or height
    myView.addConstraintsWithFormat("V:[v0(\(buttonWidth))]", views: cornerButton) // Use extension to set width or height
    myView.addConstraint(NSLayoutConstraint(item: cornerButton, attribute: .CenterX, relatedBy: .Equal, toItem: myView, attribute: .Right, multiplier: 1, constant: 0))
    myView.addConstraint(NSLayoutConstraint(item: cornerButton, attribute: .CenterY, relatedBy: .Equal, toItem: myView, attribute: .Top,   multiplier: 1, constant: 0))

// Rotation

@IBAction func angleSliderDidChange(slider: UISlider) {
    setAngle(forMyView: slider.value )

func setAngle(forMyView angle: Float) {
    let radian = angle.degreesToRadians
    myView.transform = CGAffineTransformMakeRotation( radian )

// Resize

@IBAction func widthSlider(sender: UISlider) {

    let newWidth: CGFloat = CGFloat(sender.value)

    let newSize = CGSizeMake(newWidth, myView.aspectRatioKeptHeight(forWidth: newWidth))
    myView.bounds.size = newSize



I want to ask is in the iOS how to design a control at the same time as the header and footer UITableView. Because I want to tableView sliding upwards when suspended in a tableView above slide down Suspended below. But I don't know the internal implementation principle of UITableView header There was no way to laid hands on him, so please help me

I have a requirement, when I am in and out of a preset range, need to phone records, the APP can also killed case, because the set range is large, about 100 meters, the ibeacon cannot be used

I've noticed that implementing NSURLSessionDataDelegate and starting a task will very occasionally will throw an EXC_BAD_ACCESS. The actual calling method that gives the error seems to vary but always comes from CFNetwork. For the most part, the calling method comes from NSURLSession delegate_dataTask:didReceiveData:completionHandler. I've attached two crash logs with different callers below. I've also attached my implementation of NSURLSessionDataDelegate.

Unfortunately I cannot reliably reproduce the error, so I don't have an example script to share. Creating and starting Downloader objects will eventually create the error. It does seem to happen more often with larger files. Have I implemented something wrong here? Is there a good way to debug from this stacktrace?

I've tested on iOS10 and 10.1.1 with the same results.


class Downloader: NSObject, NSURLSessionDataDelegate {
    private let url: String
    var finished = false
    let finishCondition = NSCondition()

    init(url:String) {
        self.url = url

    func start() {
        let config = NSURLSessionConfiguration.defaultSessionConfiguration()
        let session = NSURLSession(configuration: config,
                               delegate: self,
                               delegateQueue: nil)
        guard let u = NSURL(string: url) else {
        let request = NSMutableURLRequest(URL: u)
        let task = session.dataTaskWithRequest(request)

    func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask,
                    didReceiveData data: NSData) {

    func URLSession(session: NSURLSession,
                    task: NSURLSessionTask,
                    didCompleteWithError error: NSError?) {

    func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask,
                    didReceiveResponse response: NSURLResponse,
                                       completionHandler: (NSURLSessionResponseDisposition) -> Void) {

    func waitForFinish() {
        while !finished {

    func URLSession(session: NSURLSession, didBecomeInvalidWithError error: NSError?) {
        finished = true

Crash log #1:

* thread #5: tid = 0x25923, 0x0000000100042e8c libBacktraceRecording.dylib`__gcd_queue_item_enqueue_hook_block_invoke, queue = 'com.apple.NSURLSession-work', stop reason = EXC_BAD_ACCESS (code=1, address=0xf8686a68b98c6ec8)
  * frame #0: 0x0000000100042e8c libBacktraceRecording.dylib`__gcd_queue_item_enqueue_hook_block_invoke
    frame #1: 0x000000010004241c libBacktraceRecording.dylib`gcd_queue_item_enqueue_hook + 232
    frame #2: 0x000000010065dee8 libdispatch.dylib`_dispatch_introspection_queue_item_enqueue_hook + 40
    frame #3: 0x000000010063cba4 libdispatch.dylib`_dispatch_queue_push + 196
    frame #4: 0x000000018ba50500 Foundation`iop_promote_qos_outward + 112
    frame #5: 0x000000018ba4e524 Foundation`-[NSOperation setQualityOfService:] + 168
    frame #6: 0x000000018b9d7714 Foundation`-[NSOperationQueue addOperationWithBlock:] + 76
    frame #7: 0x000000018b73f82c CFNetwork`-[NSURLSession delegate_dataTask:didReceiveData:completionHandler:] + 208
    frame #8: 0x000000018b5a2c5c CFNetwork`-[__NSCFLocalSessionTask _task_onqueue_didReceiveDispatchData:completionHandler:] + 276
    frame #9: 0x000000018b5a5474 CFNetwork`-[__NSCFLocalSessionTask connection:didReceiveData:completion:] + 164
    frame #10: 0x000000018b647bf0 CFNetwork`__48-[__NSCFURLLocalSessionConnection _tick_running]_block_invoke + 120
    frame #11: 0x000000018b647b60 CFNetwork`-[__NSCFURLLocalSessionConnection _tick_running] + 344
    frame #12: 0x000000018b648c74 CFNetwork`-[__NSCFURLLocalSessionConnection _didReceiveData:] + 412
    frame #13: 0x000000018b64af8c CFNetwork`SessionConnectionLoadable::_loaderClientEvent_DidReceiveData(__CFArray const*) + 52
    frame #14: 0x000000018b6f823c CFNetwork`___ZN19URLConnectionLoader19protocolDidLoadDataEPK8__CFDatax_block_invoke_2 + 44
    frame #15: 0x000000018b64b58c CFNetwork`___ZN25SessionConnectionLoadable21withLoaderClientAsyncEU13block_pointerFvP21LoaderClientInterfaceE_block_invoke + 32
    frame #16: 0x000000010063125c libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #17: 0x000000010063121c libdispatch.dylib`_dispatch_client_callout + 16
    frame #18: 0x000000010063eb54 libdispatch.dylib`_dispatch_queue_serial_drain + 1136
    frame #19: 0x0000000100634ce4 libdispatch.dylib`_dispatch_queue_invoke + 672
    frame #20: 0x0000000100640e6c libdispatch.dylib`_dispatch_root_queue_drain + 584
    frame #21: 0x0000000100640bb8 libdispatch.dylib`_dispatch_worker_thread3 + 140
    frame #22: 0x000000018a01e2b8 libsystem_pthread.dylib`_pthread_wqthread + 1288
    frame #23: 0x000000018a01dda4 libsystem_pthread.dylib`start_wqthread + 4

Crash log #2:

* thread #12: tid = 0x2521f, 0x000000010010ae8c libBacktraceRecording.dylib`__gcd_queue_item_enqueue_hook_block_invoke, queue = 'com.apple.CFNetwork.Connection', stop reason = EXC_BAD_ACCESS (code=1, address=0xd00f524835000200)
      * frame #0: 0x000000010010ae8c libBacktraceRecording.dylib`__gcd_queue_item_enqueue_hook_block_invoke
        frame #1: 0x000000010010a41c libBacktraceRecording.dylib`gcd_queue_item_enqueue_hook + 232
        frame #2: 0x0000000100759ee8 libdispatch.dylib`_dispatch_introspection_queue_item_enqueue_hook + 40
        frame #3: 0x0000000100738ba4 libdispatch.dylib`_dispatch_queue_push + 196
        frame #4: 0x00000001975ccb3c libnetwork.dylib`nw_connection_read + 448
        frame #5: 0x00000001975d938c libnetwork.dylib`tcp_connection_read + 168
        frame #6: 0x000000018b719d54 CFNetwork`TCPIOConnection::read(unsigned long, unsigned long, void (dispatch_data_s*, CFStreamError) block_pointer) + 172
        frame #7: 0x000000018b782af4 CFNetwork`HTTPEngine::_getBodyIntelligently(void (dispatch_data_s*, CFStreamError, bool) block_pointer) + 816
        frame #8: 0x000000018b780d0c CFNetwork`HTTPEngine::_readBodyStartNextRead() + 76
        frame #9: 0x000000018b783664 CFNetwork`___ZN10HTTPEngine21_getBodyIntelligentlyEU13block_pointerFvP15dispatch_data_s13CFStreamErrorbE_block_invoke.56 + 344
        frame #10: 0x000000018b719f64 CFNetwork`___ZN15TCPIOConnection4readEmmU13block_pointerFvP15dispatch_data_s13CFStreamErrorE_block_invoke + 480
        frame #11: 0x000000010072d25c libdispatch.dylib`_dispatch_call_block_and_release + 24
        frame #12: 0x000000010072d21c libdispatch.dylib`_dispatch_client_callout + 16
        frame #13: 0x000000010073ab54 libdispatch.dylib`_dispatch_queue_serial_drain + 1136
        frame #14: 0x0000000100730ce4 libdispatch.dylib`_dispatch_queue_invoke + 672
        frame #15: 0x000000010073ce6c libdispatch.dylib`_dispatch_root_queue_drain + 584
        frame #16: 0x000000010073cbb8 libdispatch.dylib`_dispatch_worker_thread3 + 140
        frame #17: 0x000000018a01e2b8 libsystem_pthread.dylib`_pthread_wqthread + 1288
        frame #18: 0x000000018a01dda4 libsystem_pthread.dylib`start_wqthread + 4

I use WKWebView to load my webpage. When user click a button in webpage, my webpage will open a custom schema URL (e.g. asfle://download?media_id=1). And I use KVO to observe WKWebView's URL property to get the URL. It works well in iOS 9, but it doesn't work in iOS 10. I can't get the url. I use Xcode 8, swift 2.3.

override func viewDidLoad() {

        webView.addObserver(self, forKeyPath: "URL", options: .New, context: nil)

override func observeValueForKeyPath(keyPath: String?,
                                  ofObject object: AnyObject?,
                                           change: [String : AnyObject]?,
                                                  context: UnsafeMutablePointer<Void>)

In iOS 9, it can print url. But in iOS 10 only the website's url get printed, when user touch the button in webpage, nothing get printed.

I've been looking all over the internet, and can't seem to find really any information on this topic.

What are the best practices to control views and controllers based on the role of the user within the application?

For example, a driver vs passenger in a Uber like app. The view and controllers for the view would be completely different depending on the role.

I'm currently working on an alarm application , and i am implementing a smart alarm feature where i have to fetch data from server to determine whether it is the right time to wake user up.

Let's say, the case is :

  • Alarm set to 06:30AM

  • Smart alarm feature set to 30 mins before 06:30 , which the data fetching will happens 5 times with 5 minutes interval starting from 06:00AM to 06:25AM

  • If , let's say , at 06:15AM the server returned a data which is needed to wake the user up, all tasks scheduled will be cancelled immediately
  • Current time is 11:30PM
  • No smart alarm's tasks will be executed during the period of 11:30PM to 06:00AM

Since upgrading to Xcode 8.1 my UI tests that use twoFingerTap() to zoom out on a Google Maps view have been failing with

Assertion Failure: Element.swift:135: UI Testing Failure - Unable to find unoccluded area to perform event.

The message preceding that is

Recompute visible frame by excluding frames of occluding elements StatusBar and "the view's identifier"

Anyone have any idea what I should do about that? Tried tapWithNumberOfTaps(1, numberOfTouches: 2) and same thing happens.

I'm in the research (what's doable) phase of a possible app development project.

My potential app will be a trip app that lists all stores and drug stores. Is is possible for my app (regardless of platform) to integrate Google Maps (or some other maps database) to provide:

  1. turn-by-turn guided directions?
  2. interactive list of stores and drug stores between start and final destination so that I can choose my preferred stops?
  3. calculate time/distance to each chosen stop?
  4. ability to add other parameters to each stop?

I found another app that functions similar to my app idea but I'm not sure if the GPS navigation functionality and limitless list of places has to be built from scratch or can integrate with an existing tool like Google Maps API and if there's a charge if I'm charging for my app.

I have xib file which successfully loaded in view controller. In that xib I have button to navigate to specific view controller i named it HomeViewController. This HomeViewController has no problem when it being loaded from splashscreen. But, I got this fatal error: unexpectedly found nil while unwrapping an Optional value on my HomeViewController when I try to access it from my button in xib.

Here is where the nil exist

let navBarColor = navigationController!.navigationBar
    navBarColor.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
    let img = UIImage(named: "bg_navbar")
    navigationController?.navigationBar.setBackgroundImage(img, forBarMetrics: .Default)

this is my button function

    func backToHome(menuView: Receipt) {
    let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
    let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("Home") as! HomeViewController
    self.presentViewController(nextViewController, animated: true, completion: nil)

here is my action on xib class

    @IBAction func closeAction(sender: AnyObject) {

what should I do to load perfectly? Thanks guys!

it is easy for every one to creat an iOS development certificate ,but my step not use. step: log in my apple account -> certificates -> all -> iOS App Development-> continue -> continue -> choose File…(in this step i import a Certificate Signing Request file) -> continue -> fail. fail note:"An unexpected error occurred. Please try again. If the problem persists, please contact Apple Developer Program Support. https://developer.apple.com/support" i tried my best,but not use. other previews: 1.i can get a normal Production Certificate and submitted my app successfully. 2.the number of my devices is not exceed.

I am building an application in Xamarin in visual studio. I am wondering if I am going about doing my navigation all wrong. The application will have 16 screens, I am trying to use stack based navigation. Here is an example of how I am setting up the initial page and navigation from the page.

Here is the WelcomeScreenActivity:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

 namespace ConnectSafeV2
[Activity(Label = "Welcome To ConnectSafe", MainLauncher =true)]
public class WelcomeActivity : Activity
    private ImageButton recipientButton;
    private ImageButton careGiverButton;

    protected override void OnCreate(Bundle savedInstanceState)

        // Create your application here


    private void HandleEvents()
        recipientButton.Click += RecipientButton_Click;
        careGiverButton.Click += CareGiverButton_Click;

    private void CareGiverButton_Click(object sender, EventArgs e)
        var intent = new Intent(this, typeof(CaregiverWelcomeActivity));

    private void RecipientButton_Click(object sender, EventArgs e)
        var intent = new Intent(this, typeof(RecipientWelcomeActivity));

    private void FindViews()
        recipientButton = FindViewById<ImageButton>(Resource.Id.imageButtonRecipientUserType);
        careGiverButton = FindViewById<ImageButton>(Resource.Id.imageButtonCaregiver);



Here is the View file:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:text="Welcome to Connect Safe"
    android:id="@+id/textViewWelcomeSplash" />
    android:id="@+id/imageButtonRecipientUserType" />
    android:id="@+id/textViewLabelRecipient" />
    android:id="@+id/imageButtonCaregiver" />
    android:id="@+id/textViewCaregiverLabel" />
    android:id="@+id/imageButtonGoHome1" />
    android:text="Go Home"
    android:id="@+id/textViewGoHomeLabel1" />

So if I use the strategy of this code snippet:

  private void CareGiverButton_Click(object sender, EventArgs e)
        var intent = new Intent(this, typeof(CaregiverWelcomeActivity));

I am going to end up with a ton of activities and views, which part of me does not think is all that wrong, but I don't want to go too far down that path if it is bad practice. I am also feeling like there is an opportunity to re use a good amount of code. Is it bad to have like 15 or 16 different activities, a lot of them will be for navigation purposes, but there will be custom logic in many, ie push notifications, timers, location of devices etc...

If anybody has used Xamarin to develop in Andriod in C#, please let me know if I am on the right track? Thanks.

I have created a ListView in which i want to display some records from a database. This is working fine. I also want when someone clicks an item from the ListView, the correct id and product name to be displayed. In my case, every time i click an item, it is displayed only the last record. What can i do to solve this problem?

Here is my code:

public static final String ID = "id";
public static final String PRODUCT_NAME = "productName";

JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, showProductsUrl, new Response.Listener<JSONObject>() {
    public void onResponse(JSONObject response) {
        try {
            JSONArray jsonArray = response.getJSONArray("products");

            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                final String productId = jsonObject.getString("id");
                final String productName = jsonObject.getString("productName");
                HashMap<String, String> product = new HashMap<>();
                product.put(ID, productId);
                product.put(PRODUCT_NAME, productName);

                String[] from = {PRODUCT_NAME};
                int[] to = {R.id.productName};

                ListAdapter adapter = new SimpleAdapter(getApplicationContext(), productList, R.layout.list_products_to_buy, from, to);

                ListView listView = (ListView) findViewById(R.id.listView);
                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        System.out.println(productId + " " + productName);
        } catch (JSONException e) {

Thanks in advance!

I'm trying to make a 2d barcode reader (pdf 417) but the problem is the content in the barcode is Arabic content so when I scan it gives me "?????" instead of the Arabic word I tried all the apps in the app store and it gives the same result and also tried some 3rd parties from github and the same please help