I want to implement Facebook login with my app where I initiate the dialogue through my application, but all of the authentication logic goes through the server. All I want the application to do is give the user a "Sign in Through Facebook" button. The user presses this button, and thereafter I'd like all authorization to go through the server where it's handled by Passport's Facebook module and my strategy. In the end I would pass back my client some credentials, then shift views to my "home" screen.

With a browser-based application, this would be as simple as setting the "href" value of the login button to a route that calls the "passport.authenticate", and setting the redirect url to a route that upon success, would render a successful login view through the view engine.

However I'm unclear of how to integrate this server code with an iOS application as iOS views are can't be rendered by the server. I can get the login button to send a request to my server to a route that calls "passport.authenticate('facebook')", but from there I'm unsure how to coordinate server responses with what happens on the client (views switching between a FB window and the app, redirecting them to one view if succesful and back to login if not).

How could this be implemented? If I'm thinking about OAuth incorrectly, what would your recommendations be for changing my auth flow? Any input is appreciated.

When I try to profile our iMessage extension in Instruments, I get this error:

while the extension is up and running in simulator.

Any help appreciated.

I'm trying to load images in a cell using cache but it works just for the first cell the others don't load images. here's my code:

 var posts = [Post]()

 static var imageCache = NSCache<AnyObject, AnyObject>()

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let post = posts[indexPath.row]


    if let cell = tableView.dequeueReusableCell(withIdentifier: "PostCell") as? PostCell {

        cell.request?.cancel()

        var img: UIImage?

        if let url = post.imageUrl {

            img = HomeViewController.imageCache.object(forKey: url as AnyObject) as? UIImage

        }

        cell.configureCell(post: post, img: img)

        return cell

    } else {


return PostCell()
    }
}

and here's PostCell:

func configureCell(post: Post, img: UIImage?) {

    self.post = post
    self.descriptionText.text = post.postDescription
    self.likesLbl.text = "\(post.likes)"


    if post.imageUrl != nil {

        if img != nil {

        self.showcaseImg.image = img
    } else {

            request = Alamofire.request(post.imageUrl!).validate(contentType: ["image/*"]).response(completionHandler: { response in


                if response.error == nil {
                    let img = UIImage(data: response.data!)!
                    self.showcaseImg.image = img
                    HomeViewController.imageCache.setObject(img, forKey: self.post.imageUrl! as AnyObject)
                }


            })
        }
    } else {
        self.showcaseImg.isHidden = true
    }


}

where can be the problem? It seems that the first cell works fine but the others don't load any images, although the images url are stored in Firebase

Is it possible to use email verification with Parse Server and AWS using Swift as the language (Xcode)? If so, please explain how this is achieved and the necessary steps required to add this functionality to an app (or provide a good link)? If not, please explain why and where any alternatives may exist.

I have used AFNetworking in my project, whenever i sent request,Im getting this message in failure block,

Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unauthorized (401)" UserInfo={com.alamofire.serialization.response.error.response= com.alamofire.serialization.response.error.data=<7b227375 63636573 73223a66 616c7365 2c226d65 73736167 65223a22 41757468 656e7469 63617469 6f6e2066 61696c65 64227d>, NSLocalizedDescription=Request failed: unauthorized (401)}

This is how I'm sending request by using AFNetworking.

AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:BASE_URL]];

manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", nil];

NSString *path = [NSString stringWithFormat:@"/api/##/##/##/sign_in"];

NSString *params = @"{\"user\": {\"uid\": \"10236412002551\",\"access_token\":\"g6tdbvc34seadcx7yufbbcgvf8ijhss\",\"email\": \"user@domain1.com\",\"latitude\": \"6.927079\",        \"longitude\": \"79.861243\",\"remote_avatar_url\": \"\"}}";

manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];

AFSecurityPolicy* policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
[policy setValidatesDomainName:NO];
[policy setAllowInvalidCertificates:YES];

[manager POST:path parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
    if([[responseObject objectForKey:@"error_code"] intValue]==0){
        if (success) {
           success(userArray);
        }
     }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

But If I will be able to get the correct response by using NSURLSession.(Please refer below code)

    NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
    NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: nil delegateQueue: [NSOperationQueue mainQueue]];

    NSURL * url = [NSURL URLWithString:@"http://##/api/##/##/##/sign_in"];
    NSMutableURLRequest * urlRequest = [NSMutableURLRequest requestWithURL:url];

    NSString * params =@"{\"user\": {\"uid\": \"10236412002551\",\"access_token\":\"g6tdbvc34seadcx7yufbbcgvf8ijhss\",\"email\": \"user@domain1.com\",\"latitude\": 6.927079,        \"longitude\": 79.861243,\"remote_avatar_url\": \"\"}}";

    [urlRequest addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [urlRequest setHTTPMethod:@"POST"];
    [urlRequest setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];

    NSURLSessionDataTask * dataTask =[defaultSession dataTaskWithRequest:urlRequest
                                                       completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                           NSLog(@"Response:%@ %@\n", response, error);
                                                           if(error == nil)
                                                           {
                                                               NSString * text = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];

                                                               NSDictionary * json  = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

                                                               NSLog(@"Data = %@",text);
                                                               NSLog(@"Data = %@",json);
                                                           }

                                                       }];
    [dataTask resume];

I'm interested in using AFNetworking,But due to this issue I won't be able to move forward. Please help me to correct the issue with AFNetworking.

This is the request I should send,

{ 
    "user": {
       "uid": "102364120025511",
       "access_token": "g6tdbvc34seadcx7yufbbcgaavf8ijh",
       "email": "user@domain.com",
       "latitude": 6.927079,
       "longitude": 79.861243,
       "remote_avatar_url": ""
    }
}

This is the response I should get,

{
  "success": true,
  "message": "Successfully authenticated",
  "user": {
    "id": 123,
    "email": "user@domain.com",
    "provider": "facebook",
    "latitude": 6.927079,
    "longitude": 79.861243,
    "avatar": {
      "url": "",
      "thumb": ""
    }
  }
}

I have cloudkit notifications working. When someone changes the record, the subscribers are notified. My subscription definition looks like:

         NSPredicate *searchConditions = [NSPredicate predicateWithFormat:@"%K = %@", CLOUDKIT_PUBLIC_ID_GUID, theCloudGUID];
         int subscriptionOptions = CKSubscriptionOptionsFiresOnRecordUpdate | CKSubscriptionOptionsFiresOnRecordDeletion;
         CKSubscription *publicSubscription = [[CKSubscription alloc] initWithRecordType:CLOUDKIT_RECORDNAME_PUBLIC_ID
                                                                               predicate:searchConditions
                                                                                 options:subscriptionOptions];

         CKNotificationInfo *notificationInfo = [CKNotificationInfo new];
         notificationInfo.alertLocalizationKey = CLOUDKIT_NOTIFICATION_PUBLIC;
         notificationInfo.shouldBadge = NO;
         notificationInfo.alertBody = CLOUDKIT_NOTIFICATIONBODY_PUBLIC;
         publicSubscription.notificationInfo = notificationInfo;

         [publicDatabase saveSubscription:publicSubscription completionHandler:^(CKSubscription * _Nullable subscription, NSError * _Nullable error)
          {
              //error handling
          }

The thing is, there are multiple fields in this record. I only want to alert the subscriber when one specific field changes.

When creating the subscription, is there a way to set the search predicate to detect a change in a specific field? I read through the various Predicate docs, but didn't see this specifically mentioned.

Or, when receiving the notification, is there a way to see which fields changed? In didReceiveRemoteNotification I tried:

 CKQueryNotification *queryNotification = [CKQueryNotification notificationFromRemoteNotificationDictionary:userInfo]; 

But queryNotification.recordFields is null.

As a worst case, I have considered breaking the specific field out into it's own record, but then I have the overhead of maintaining more records tied together by a common GUID. I was hoping to keep this more compact.

Description

I installed CocoaPods and opened the xcworkspace in Xcode but I get this error when trying to build:

Ld /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator/CocoaPodsFailure.app/PlugIns/CocoaPodsFailureTests.xctest/CocoaPodsFailureTests normal x86_64
    cd /Users/Robert/Code/_Playing/react-native-cocoapods/CocoaPodsFailure/ios
    export IPHONEOS_DEPLOYMENT_TARGET=8.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk -L/Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator -F/Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -filelist /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Intermediates/CocoaPodsFailure.build/Debug-iphonesimulator/CocoaPodsFailureTests.build/Objects-normal/x86_64/CocoaPodsFailureTests.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -mios-simulator-version-min=8.0 -bundle_loader /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator/CocoaPodsFailure.app/CocoaPodsFailure -Xlinker -object_path_lto -Xlinker /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Intermediates/CocoaPodsFailure.build/Debug-iphonesimulator/CocoaPodsFailureTests.build/Objects-normal/x86_64/CocoaPodsFailureTests_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -framework XCTest /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator/libReact.a -lPods-CocoaPodsFailureTests -Xlinker -dependency_info -Xlinker /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Intermediates/CocoaPodsFailure.build/Debug-iphonesimulator/CocoaPodsFailureTests.build/Objects-normal/x86_64/CocoaPodsFailureTests_dependency_info.dat -o /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator/CocoaPodsFailure.app/PlugIns/CocoaPodsFailureTests.xctest/CocoaPodsFailureTests

Undefined symbols for architecture x86_64:
  "std::__1::__next_prime(unsigned long)", referenced from:
      std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::rehash(unsigned long) in libReact.a(RCTJSCExecutor.o)
  "std::__1::mutex::lock()", referenced from:
      -[RCTModuleData setUpInstanceAndBridge] in libReact.a(RCTModuleData.o)
      cachedSystemFont(double, double) in libReact.a(RCTFont.o)
  "std::__1::mutex::unlock()", referenced from:
      -[RCTModuleData setUpInstanceAndBridge] in libReact.a(RCTModuleData.o)
      cachedSystemFont(double, double) in libReact.a(RCTFont.o)
  "std::__1::mutex::~mutex()", referenced from:
      -[RCTModuleData .cxx_destruct] in libReact.a(RCTModuleData.o)
      cachedSystemFont(double, double) in libReact.a(RCTFont.o)
  "std::terminate()", referenced from:
      ___clang_call_terminate in libReact.a(RCTJSCExecutor.o)
  "operator delete[](void*)", referenced from:
      -[RCTJSCExecutor dealloc] in libReact.a(RCTJSCExecutor.o)
      executeRandomAccessModule(RCTJSCExecutor*, unsigned int, unsigned long, unsigned long) in libReact.a(RCTJSCExecutor.o)
      readRAMBundle(std::__1::unique_ptr<__sFILE, int (*)(__sFILE*)>, RandomAccessBundleData&) in libReact.a(RCTJSCExecutor.o)
      RandomAccessBundleData::~RandomAccessBundleData() in libReact.a(RCTJSCExecutor.o)
  "operator delete(void*)", referenced from:
      std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::~__hash_table() in libReact.a(RCTJSCExecutor.o)
      std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::__deallocate(std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*>*) in libReact.a(RCTJSCExecutor.o)
      ____ZL37installBasicSynchronousHooksOnContextP9JSContext_block_invoke_6 in libReact.a(RCTJSCExecutor.o)
      std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*>, std::__1::__hash_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*> > > > std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::__construct_node_hash<std::__1::pair<unsigned long const, unsigned long> const&>(unsigned long, std::__1::pair<unsigned long const, unsigned long> const&&&) in libReact.a(RCTJSCExecutor.o)
      std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::__rehash(unsigned long) in libReact.a(RCTJSCExecutor.o)
      std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::erase(std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*>*>) in libReact.a(RCTJSCExecutor.o)
  "operator new[](unsigned long)", referenced from:
      executeRandomAccessModule(RCTJSCExecutor*, unsigned int, unsigned long, unsigned long) in libReact.a(RCTJSCExecutor.o)
      readRAMBundle(std::__1::unique_ptr<__sFILE, int (*)(__sFILE*)>, RandomAccessBundleData&) in libReact.a(RCTJSCExecutor.o)
  "operator new(unsigned long)", referenced from:
      std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*>, std::__1::__hash_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*> > > > std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::__construct_node_hash<std::__1::pair<unsigned long const, unsigned long> const&>(unsigned long, std::__1::pair<unsigned long const, unsigned long> const&&&) in libReact.a(RCTJSCExecutor.o)
      std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::__rehash(unsigned long) in libReact.a(RCTJSCExecutor.o)
  "___cxa_begin_catch", referenced from:
      ___clang_call_terminate in libReact.a(RCTJSCExecutor.o)
  "___cxa_guard_acquire", referenced from:
      cachedSystemFont(double, double) in libReact.a(RCTFont.o)
  "___cxa_guard_release", referenced from:
      cachedSystemFont(double, double) in libReact.a(RCTFont.o)
  "___gxx_personality_v0", referenced from:
      -[RCTJavaScriptContext initWithJSContext:onThread:] in libReact.a(RCTJSCExecutor.o)
      -[RCTJavaScriptContext init] in libReact.a(RCTJSCExecutor.o)
      -[RCTJavaScriptContext invalidate] in libReact.a(RCTJSCExecutor.o)
      +[RCTJSCExecutor runRunLoopThread] in libReact.a(RCTJSCExecutor.o)
      -[RCTJSCExecutor setBridge:] in libReact.a(RCTJSCExecutor.o)
      -[RCTJSCExecutor init] in libReact.a(RCTJSCExecutor.o)
      -[RCTJSCExecutor initWithUseCustomJSCLibrary:] in libReact.a(RCTJSCExecutor.o)
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reproduction

Managed to reproduce it with a fresh project:

  1. react-native init
  2. react-native run-ios (running ok)
  3. pod init && pod install (no dependencies added)
  4. Build from XCode (or react-native run-ios)

Here is an example project (just run npm install and react-native run-ios to reproduce with this example project) CocoaPodsFailure.zip

Additional Information

  • React Native version: 0.36.1
  • Platform: iOS
  • Operating System: MacOS

New to swift and the view controller paradigm. Would like to know if ViewControllers automatically come with the objects it describes for example, does avplayerviewcontroller automatically come with an avplayer object ready to be used or do we still need to create an avplayer object? Another example could be uitableviewcontroller, does it automatically come with a tableview object or do we need to create it after creating a cocoa touch class that subclasses uitableviewcontroller.

Here is some example code that compiles where I didn't necessarily create an avplayer object but it seems like that object was already ready to be used through a property called 'player':

import UIKit
import AVKit
import AVFoundation

class MeetTheAuthorViewController: UIViewController {



    override func viewDidLoad() {
        super.viewDidLoad()
        //playBackgroundMusic("bensound-jazzyfrenchy-castlesbackground.mp3")
        // Do any additional setup after loading the view.


    }

    func btn_clicked(_ sender: UIBarButtonItem) {
        // Do something
    }

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == "videoSegue"
        {
            //set up the player
            let videoURL = Bundle.main.url(forResource: "The Atlanta Goat_ Part One-HD", withExtension: "mp4")
            let videoViewController = segue.destination as! AVPlayerViewController
            videoViewController.player = AVPlayer(url: videoURL!)
            videoViewController.player?.play()


        }
    }


}

How can i use value of Port in the Post-SQL of Source Qualifier ?

Here is my Source qualifier. Click to see image

I work on an application, the core of which is a very complex set of web forms. The source of this complexity

  1. scale, some forms contain about 50 pages, which up to 30 questions on each page
  2. complex rules, e.g. if the user answers "no" to question 4, then questions 5-15 do not apply, so should be removed from the form

Currently we use Angular Schema Form for the forms, but it doesn't provide a compelling way to manage large number of complex rules among form fields.

I don't have much experience with rules-based programming, but it seems to me that this might provide a better way of managing the rules among form fields. For example, using a rules-based approach we could define the rules associated with each form field, and the rules engine could use these to decide which field(s) to display next. Using our current approach, we achieve this with a massive amount of imperative JavaScript which is almost impossible to test and maintain.

If anyone has experience with developing such complex web forms, I'd be interested to hear about their experience e.g. tools/libraries they could recommend. Our current stack is based on the JDK (Java, Groovy, Grails) and JavaScript (Angular, Node) so tools/libraries/frameworks that run on those platforms would be of particular interest.

I have a class that extends Game, them a bunch of other classes that implements Screen and because of that I can just do this game.setScreen(new MyScreen(game)); but the problem is that when I do Gdx.app.exit() it just closes the current screen and go to the next, this is the same for game.dispose(). So how do you close it when it's running as desktop or android application?

I have an issue that I can't explain why it happened because I try to debug this for hours. My application runs succeed so it is nothing about import Python library. But it always crash when i press a button to send message through bluetooth using python socket. (App written using kivy framework and using buildozer to build apk file)

import socket

def callback(self,instance,pos): # function called when button click to send text typed in text input box 
    a = self.text   # it is text that in text input box
    macadd = '20:15:ff:7e:bc:9a'
    port = 1
    s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)   # this line cause the crash

Then I type command:

buildozer init
buildozer -v android debug

file buildozer.spec doesn't change. Everything is ok and I install in my Android 4.0 using API 21. Here is the problem: WHEN I COMMENT

#s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)

My app run and when click the button to submit, nothing happend, it's ok as function does. BUT WHEN I REMOVE COMMENT:

s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)

My app run and when click the button to submit, it's crashed. I don't know what to do now. I really need somebody can help me with this situation. So thank you.

I have BitmapScalingHelper.java

public class BitmapScalingHelper
{
    public static Bitmap decodeResource(Resources res, int resId, int dstWidth, int dstHeight)
    {
        Options options = new Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeResource(res, resId, options);
        options.inJustDecodeBounds = false;

        options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, dstWidth,
                dstHeight);

        Bitmap unscaledBitmap = BitmapFactory.decodeResource(res, resId, options);

        return unscaledBitmap;
    }

    public static Bitmap decodeFile(String filePath, int dstWidth, int dstHeight)
    {
        Options options = new Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(filePath, options);

        options.inJustDecodeBounds = false;
        options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, dstWidth,
                dstHeight);

        Bitmap unscaledBitmap = BitmapFactory.decodeFile(filePath, options);

        return unscaledBitmap;
    }


    public static int calculateSampleSize(int srcWidth, int srcHeight, int dstWidth, int dstHeight)
    {
        final float srcAspect = (float)srcWidth / (float)srcHeight;
        final float dstAspect = (float)dstWidth / (float)dstHeight;

        if (srcAspect > dstAspect)
        {
            return srcWidth / dstWidth;
        }
        else
        {
            return srcHeight / dstHeight;
        }
    }

    public static Bitmap createScaledBitmap(Bitmap unscaledBitmap, int dstWidth, int dstHeight)
    {
        Rect srcRect = calculateSrcRect(unscaledBitmap.getWidth(), unscaledBitmap.getHeight());

        Rect dstRect = calculateDstRect(unscaledBitmap.getWidth(), unscaledBitmap.getHeight(),
                dstWidth, dstHeight);

        Bitmap scaledBitmap = Bitmap.createBitmap(dstRect.width(), dstRect.height(),
                Config.ARGB_8888);

        Canvas canvas = new Canvas(scaledBitmap);
        canvas.drawBitmap(unscaledBitmap, srcRect, dstRect, new Paint(Paint.FILTER_BITMAP_FLAG));

        return scaledBitmap;
    }

    public static Rect calculateSrcRect(int srcWidth, int srcHeight)
    {
        System.out.print("Scr" + srcWidth + " " + srcHeight);
        return new Rect(0, 0, srcWidth, srcHeight);
    }

    public static Rect calculateDstRect(int srcWidth, int srcHeight, int dstWidth, int dstHeight)
    {
        final float srcAspect = (float)srcWidth / (float)srcHeight;
        final float dstAspect = (float)dstWidth / (float)dstHeight;

        if (srcAspect > dstAspect)
        {
            return new Rect(0, 0, dstWidth, (int)(dstWidth / srcAspect));
        }
        else
        {
            return new Rect(0, 0, (int)(dstHeight * srcAspect), dstHeight);
        }
    }
}

In this class there is

createScaledBitmap()

which returns scaled bitmap for image.

In another class i have this method

public Bitmap readSelectedBitmapFromFile(Context context, String fileName)
    {
        DisplayMetrics metrics = new DisplayMetrics();
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        windowManager.getDefaultDisplay().getMetrics(metrics);

        Bitmap scaledBitmap = getDefaultBitmap(context);

        try {
            File themeParentDir = context.getDir(THEME_DIRECTORY_NAME, Context.MODE_PRIVATE); //Creating an internal dir;
            File themeSubDir = new File(themeParentDir, THEME_SUB_DIRECTORY_NAME + getThemeBasedDirectoryNumber(m_SelectedTheme));
            themeSubDir.mkdir();

            File themeFileWithinDir = new File(themeSubDir, fileName); //Getting a file within the dir.

            if(themeFileWithinDir.exists())
            {
                // Part 1: Decode image
                Bitmap unscaledBitmap = BitmapScalingHelper.decodeFile(themeFileWithinDir.getPath(), metrics.widthPixels, metrics.heightPixels);

                // Part 2: Scale image
                scaledBitmap = BitmapScalingHelper.createScaledBitmap(unscaledBitmap, metrics.widthPixels, metrics.heightPixels);
                unscaledBitmap.recycle();
            }

            m_SelectedBitmap = scaledBitmap;

        }
        catch (Error e) {
            e.printStackTrace();
        }

        return scaledBitmap;
    }

This code was working fine in many devices. But it was crashing in some devices, can any one please help me out ?

I am getting log like this

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3254)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
       at android.app.ActivityThread.access$1100(ActivityThread.java:222)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:158)
       at android.app.ActivityThread.main(ActivityThread.java:7229)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
       at in.plackal.lovecyclesfree.util.BitmapScalingHelper.createScaledBitmap(SourceFile:62)
       at in.plackal.lovecyclesfree.general.ThemeManager.readSelectedBitmapFromFile(SourceFile:202)
       at in.plackal.lovecyclesfree.activity.SplashActivity.onCreate(SourceFile:70)
       at android.app.Activity.performCreate(Activity.java:6876)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
       at android.app.ActivityThread.access$1100(ActivityThread.java:222)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:158)
       at android.app.ActivityThread.main(ActivityThread.java:7229)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

If it's permission issue, it should not crash in below Android-M version but it is crashing in some pre Android-M devices also.

I'm using Firebase Storage in my android app.

I want to give an option to display all files with their name & size, before the user downloads any file.

Image from GCP storage bucket

enter image description here

So I want metadata of all files just by mentioning their parent_folder_name.

Does firebase provide any method for that? Whatever I found in the documentation requires to provide the filename in the path.

I recently tried to implement the soundcloud user profile , but i failed multiple times , tried implementing with new collapsing does toolbar , but now where close the effect these has -

title here

Am hoping a point in the right direction , any direction would be appreciation

 <android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:fitsSystemWindows="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="false"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <include
            android:layout_width="match_parent"
            android:layout_height="200dp"
            layout="@layout/profile_header"/>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            style="@style/App.Toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    </android.support.design.widget.CollapsingToolbarLayout>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        app:tabIndicatorColor="@android:color/darker_gray"
        app:tabTextColor="@android:color/darker_gray"
        android:background="@android:color/white"
        app:tabSelectedTextColor="@android:color/black"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</android.support.design.widget.AppBarLayout>

and for the profile header

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:funky="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff">


<android.support.v7.widget.CardView
    android:id="@+id/user_prof_card"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_marginLeft="20dp"
    android:layout_marginTop="20dp"
    funky:cardCornerRadius="50dp">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/user_prof_avatar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:src="@drawable/intruder_shanky" />

</android.support.v7.widget.CardView>

<TextView
    android:textAppearance="@style/TextAppearance.AppCompat.Medium"
    android:id="@+id/user_prof_name"
    android:layout_width="match_parent"
    android:gravity="center"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/user_prof_card"
    android:layout_marginLeft="28dp"
    android:layout_toRightOf="@+id/user_prof_card"
    android:text="Intruder Shanky"
    android:textColor="#000"
     />


<RelativeLayout
    android:layout_toRightOf="@+id/user_prof_card"
    android:layout_below="@+id/user_stat"
    android:layout_width="match_parent"
    android:gravity="center"

    android:layout_height="wrap_content">

    <TextView
        android:drawableLeft="@drawable/round_follow_icon"
        android:drawablePadding="4dp"
        android:textAppearance="@style/TextAppearance.AppCompat.Small"
        android:id="@+id/user_prof_follow_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="28dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/border"
        android:paddingLeft="8dp"
        android:gravity="center"
        android:paddingRight="8dp"
        android:text="Following"
        android:textColor="@color/green" />


</RelativeLayout>



<LinearLayout
    android:layout_below="@id/user_prof_name"
    android:layout_marginLeft="28dp"
    android:layout_marginTop="4dp"
    android:layout_toRightOf="@+id/user_prof_card"
    android:id="@+id/user_stat"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical">

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">


        <LinearLayout
            android:gravity="center_vertical"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical">

            <TextView
                android:id="@+id/user_prof_follower"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="2"
                    android:textAppearance="@style/TextAppearance.AppCompat.Small"
                android:textColor="#880E4F"
                android:textStyle="bold" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:textSize="11sp"
                android:maxLines="1"
                android:text="Follower"
                android:textColor="#cc424242" />
        </LinearLayout>

        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp"
            android:background="#66424242" />

        <LinearLayout
            android:gravity="center_vertical"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical">

            <TextView
                android:id="@+id/user_prof_following"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="1782"
                  android:textAppearance="@style/TextAppearance.AppCompat.Small"
                android:textColor="#880E4F"
                android:textStyle="bold" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:textSize="11sp"
                android:maxLines="1"
                android:text="Following"
                android:textColor="#cc424242" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

<View
    android:layout_alignParentBottom="true"
    android:background="@color/grey_200"
    android:layout_width="match_parent"
    android:layout_height="6dp"/>

How is possible to autoplay audio with HTML5 JavaScript audio.play() after a first song is played with smartphone android or iphone, because I've read that autoplay it is not possible unless in android you set the chrome:flag etc. as to my understanding android chrome and iphone safari disables autoplay (unless a touch issue by user) to avoid consuming data etc and only in firefox works autoplay.

But I find some sites that once first touch by user, so once first song is playing, then the next songs are auto played automatically without user intervention. How is possible ?

I am using this plugin for database. https://github.com/litehelpers/Cordova-sqlite-storage

Now in android, I have made database through android studio which I want to access through cordova.

Is it possible?

I just want to fetch data through cordova. Data insertion is done by android.

I created a contacts app, and I wish to replace the default contacts app. The problem is that their icon is in the bottom location of the home-screen.

Even if the user would like to use my app, they will constantly get a reminder of the old system contacts app, in the most central place of the device. How can you compete that?

So is there anything I can do?

  • Can I replace the default contacts app icon in the bottom of the home screen?
  • Is there a way to track when default contacts is launched and launch my app instead?
  • Is there anything else that can be done here?

Note, I am aware of the ability to place your app shortcut in the home screen. And also I am aware of the intent to show a specific contact,call a number and send SMS, in this question I only want to talk about the scenario that app is launched from icon.

It is a time to make first little reliase. During building process i got such error

Information:Gradle tasks [:Application:assembleRelease] Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find superclass or interface java.awt.datatransfer.Transferable Warning:org.apache.harmony.awt.datatransfer.NativeClipboard: can't find superclass or interface java.awt.datatransfer.Clipboard Warning:com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.Sasl Warning:com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslClient Warning:com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslException Warning:com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslClient Warning:com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslException Warning:com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.auth.callback.NameCallback Warning:com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.sasl.RealmCallback Warning:com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.sasl.RealmChoiceCallback Warning:com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.auth.callback.NameCallback Warning:com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.sasl.RealmCallback Warning:com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.sasl.RealmChoiceCallback Warning:javax.activation.CommandInfo: can't find referenced class java.beans.Beans Warning:org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit Warning:org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment Warning:org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit Warning:org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment Warning:org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.dnd.DropTargetContext Warning:org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.dnd.peer.DropTargetContextPeer Warning:org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.dnd.DragGestureEvent Warning:org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.dnd.peer.DragSourceContextPeer Warning:org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DTK: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.DataProvider: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.Transferable Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.UnsupportedFlavorException Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.Image Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.UnsupportedFlavorException Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.DirectColorModel Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.DataBufferInt Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.Raster Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.ComponentColorModel Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.color.ColorSpace Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.ComponentColorModel Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.DataBufferByte Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.Raster Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.DataBufferUShort Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.BufferedImage Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.Image Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.BufferedImage Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.ColorModel Warning:org.apache.harmony.awt.datatransfer.DataProxy: can't find referenced class java.awt.image.WritableRaster Warning:org.apache.harmony.awt.datatransfer.DataSnapshot: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.DataSnapshot: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.Transferable Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.Transferable Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.Image Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.image.BufferedImage Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.Image Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.image.BufferedImage Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.Graphics Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.image.BufferedImage Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.image.WritableRaster Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.image.DataBufferInt Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.Transferable Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.Image Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.image.BufferedImage Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.Graphics Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.image.BufferedImage Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.image.DataBufferInt Warning:org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.Point Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceContext Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceEvent Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceContext Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceDropEvent Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceDragEvent Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceContext Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.Point Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceContext Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.Point Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceContext Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.Point Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceContext Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.Point Warning:org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceDragEvent Warning:org.apache.harmony.awt.datatransfer.FlavorsComparator: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.NativeClipboard: can't find referenced class java.awt.datatransfer.Clipboard Warning:org.apache.harmony.awt.datatransfer.TextFlavor: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.TextFlavor: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.TextFlavor: can't find referenced class java.awt.datatransfer.DataFlavor Warning:org.apache.harmony.awt.datatransfer.TextFlavor: can't find referenced class java.awt.datatransfer.SystemFlavorMap Warning:org.apache.harmony.awt.datatransfer.TextFlavor: can't find referenced class java.awt.datatransfer.DataFlavor Warning:there were 247 unresolved references to classes or interfaces. Warning:Exception while processing task java.io.IOException: Please correct the above warnings first. Error:Execution failed for task ':Application:transformClassesAndResourcesWithProguardForRelease'. java.io.IOException: Please correct the above warnings first. Information:BUILD FAILED Information:Total time: 18.423 secs Information:1 error Information:110 warnings Information:See complete output in console

and can't undestand how to fix them?

Could you help me

Thanks in advance

I'm trying understanding how Android measures and lays out views. I created a sample app with custom views and view groups.

CustomViewGroup

public class CustomViewGroup extends ViewGroup {

    private static final String LOG_TAG = "CustomViewGroup";

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

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        Log.d(LOG_TAG, String.format(Locale.ENGLISH,
                getTag() + " " +
                        "onMeasure(widthMeasureSpec=%d, heightMeasureSpec%d)",
                widthMeasureSpec, heightMeasureSpec
        ));

        final int count = getChildCount();
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() != View.GONE) {
                // Make or work out measurements for children here (MeasureSpec.make...)
                measureChild(child, widthMeasureSpec, heightMeasureSpec);
            }
        }
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        Log.d(LOG_TAG, String.format(Locale.ENGLISH,
                getTag() + " " +
                        "onLayout(changed=%b, left=%d, top=%d, right=%d, bottom=%d)",
                changed, left, top, top, right, bottom
        ));
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Log.d(LOG_TAG, getTag() + " " + "onDraw");
    }
}

CustomView

public class CustomView extends View {

    private static final String LOG_TAG = "CustomView";

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

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        Log.d(LOG_TAG, String.format(Locale.ENGLISH,
                getTag() + " " +
                "onLayout(changed=%b, left=%d, top=%d, right=%d, bottom=%d)",
                changed, left, top, top, right, bottom
        ));
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Log.d(LOG_TAG, getTag() + " " +"onDraw");
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        Log.d(LOG_TAG, String.format(Locale.ENGLISH,
                getTag() + " " +
                "onMeasure(widthMeasureSpec=%d, heightMeasureSpec=%d)",
                widthMeasureSpec, heightMeasureSpec
        ));
    }
}

MainActivity

public class MainActivity extends AppCompatActivity {

    private View mCustomGroup1;
    private View mCustomGroup2;
    private View mContainer;

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

        Log.d("MainAct", "onCreate");
        mCustomGroup1 = findViewById(R.id.requestLayout);
        mCustomGroup2 = findViewById(R.id.requestLayout2);
        mContainer = findViewById(R.id.activity_main);

        findViewById(R.id.requestLayoutBtn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCustomGroup1.requestLayout();
            }
        });

        findViewById(R.id.requestLayoutBtn2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCustomGroup2.requestLayout();
            }
        });

        findViewById(R.id.requestLayoutContBtn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mContainer.requestLayout();
            }
        });

    }
}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="ru.dmitriev.squareorderedlayout.MainActivity">

    <Button
        android:id="@+id/requestLayoutBtn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="requestLayout" />

    <Button
        android:id="@+id/requestLayoutBtn2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="requestLayout2" />

    <Button
        android:id="@+id/requestLayoutContBtn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="requestLayoutCont" />

    <ru.dmitriev.squareorderedlayout.CustomViewGroup
        android:id="@+id/requestLayout"
        android:layout_width="100dp"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#7f7"
        android:tag="CustomVieGroup1">

        <ru.dmitriev.squareorderedlayout.CustomView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:tag="CustomView11" />

        <ru.dmitriev.squareorderedlayout.CustomView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:tag="CustomView12" />
    </ru.dmitriev.squareorderedlayout.CustomViewGroup>

    <ru.dmitriev.squareorderedlayout.CustomViewGroup
        android:id="@+id/requestLayout2"
        android:layout_width="100dp"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#f77"
        android:tag="CustomVieGroup2">

        <ru.dmitriev.squareorderedlayout.CustomView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:tag="CustomView21" />

        <ru.dmitriev.squareorderedlayout.CustomView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:tag="CustomView22" />

    </ru.dmitriev.squareorderedlayout.CustomViewGroup>
</LinearLayout>

When the activity starts, onMeasure, onLayout and onDraw are called on the view groups tagged CustomVieGroup1 and CustomVieGroup2. Each view group calls these methods on their children. It's OK. I understand it.

When I call requestLayout on the view group tagged CustomVieGroup1, onMeasure, onLayout and onDraw are called on CustomVieGroup1. The group calls these methods on their children. I understand it.

When I call requestLayout on the view group tagged CustomVieGroup2, onMeasure, onLayout and onDraw are called on CustomVieGroup2. The group calls these methods on their children. I understand it as well.

But when I call requestLayout on the view with id activity_main, onMeasure and onLayout are not called on CustomVieGroup1 or CustomVieGroup2. Why? I expected that onMeasure, onLayout and onDraw will be called on both CustomVieGroup1 and CustomVieGroup2 (i.e. the cgildren of the view with id activity_main)

According to the documentation of requestLayout:

This will schedule a layout pass of the view tree.

i'm trying to write text on a bitmap and i need a edittexr in order to check inputs from keyboard . i find this code for draw EditText on the Canvas but it return null:

Attempt to invoke virtual method 'void android.widget.EditText.setDrawingCacheEnabled(boolean)' on a null object reference

Edit: Full class


public class TextMenu {
 private final Toolbox toolbox;
 private final AppPanel appPanel;
 private final Context context;
 private final MainActivity mainActivity;
 private final Resources resources;
 private Bitmap textTool, Click, textPlace;
 private final float xscaleFactor, yscaleFactor;
 private boolean allowDraw;
 private EditText editText; 

public TextMenu(Context context, Resources resources, float xscaleFactor, float yscaleFactor, Toolbox toolbox, AppPanel appPanel, MainActivity mainActivity) {
    this.xscaleFactor = xscaleFactor;
    this.yscaleFactor = yscaleFactor;
    this.resources = resources;
    this.toolbox = toolbox;
    this.appPanel = appPanel;
    this.context = context;
    this.mainActivity = mainActivity;

    textPlace = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(resources, R.drawable.text_place), (int) (xscaleFactor * 93), (int) (yscaleFactor * 193), true);
    textTool = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(resources, R.drawable.text_menu), (int) (xscaleFactor * 480), (int) (yscaleFactor * 100), true);
    Click = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(resources, R.drawable.tools_click), (int) (xscaleFactor * 80), (int) (yscaleFactor * 80), true);

    EditText editText;
    editText = new EditText(context);
    editText.setText("My Text");
    editText.setWidth(180);
    editText.setBackgroundColor(Color.WHITE);

}

public void draw(Canvas canvas) {
    if (allowDraw) {
        canvas.drawBitmap(textTool, 0, screenH - textTool.getHeight(), null);
        command(canvas);
        editText.setDrawingCacheEnabled(true);
//            editText.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
//                    View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
            editText.buildDrawingCache(true);
            Bitmap b = editText.getDrawingCache();
            canvas.drawBitmap(b, 100, 100, null);
            // editText.draw(canvas);
            mainActivity.getKeyboard();
        }
    }
}

how can i do that?