As we know, Android will force kill processes to recycle memory for more important tasks.

So, what will happen to in-flight disk writing when Android kills processes?

For example, my process was unfortunately killed when it was writing a long ArrayList to disk. When my app/process starts again some time in the future, will I get a corrupted storage in which half of the elements of the ArrayList reside? Or is there some mechanism to promise that, say, processes won't be killed when there is some in-flight disk writing ?

Further more, how does Android SharedPreference address this issue?

my class code is here :

public class Application {
    private static final String TAG = "fset.entrance.Application";
    public static Frame froot=null;

    public static void initial(){
        if (froot != null){
            return ;
        froot = new Frame("fset","FrameSet");

my activity is here

public class FrameEntranceActivity extends Activity {
    private static final String TAG = "fset.entrance.FrameEntranceActivity";

    protected void onCreate(Bundle savedInstanceState) {

logcat of android is here

09-05 02:00:28.350: E/AndroidRuntime(1891):     at
09-05 02:00:28.350: E/AndroidRuntime(1891):     at
09-05 02:00:28.350: E/AndroidRuntime(1891):     at$600(
09-05 02:00:28.350: E/AndroidRuntime(1891):     at$H.handleMessage(
09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.os.Handler.dispatchMessage(
09-05 02:00:28.350: E/AndroidRuntime(1891):     at android.os.Looper.loop(
09-05 02:00:28.350: E/AndroidRuntime(1891):     at
09-05 02:00:28.350: E/AndroidRuntime(1891):     at java.lang.reflect.Method.invokeNative(Native Method)
09-05 02:00:28.350: E/AndroidRuntime(1891):     at java.lang.reflect.Method.invoke(
09-05 02:00:28.350: E/AndroidRuntime(1891):     at$
09-05 02:00:28.350: E/AndroidRuntime(1891):     at
09-05 02:00:28.350: E/AndroidRuntime(1891):     at dalvik.system.NativeStart.main(Native Method)
09-05 02:00:28.350: E/AndroidRuntime(1891): Caused by: java.lang.NullPointerException
09-05 02:00:28.350: E/AndroidRuntime(1891):     at fset.entrance.Application.initial(
09-05 02:00:28.350: E/AndroidRuntime(1891):     at fset.entrance.FrameEntranceActivity.onCreate(
09-05 02:00:28.350: E/AndroidRuntime(1891):     at
09-05 02:00:28.350: E/AndroidRuntime(1891):     at
09-05 02:00:28.350: E/AndroidRuntime(1891):     at
09-05 02:00:28.350: E/AndroidRuntime(1891):     ... 11 more

After finding solutions from stackoverflow , I learned that not any static variable could be created successly when AVD start , but, I have no idea about these rules systemly, I want some help could clarify my incomplete understanding .

I have a code where user can move a transparent rectangle on the screen.

The issue i am facing is the rectangle when i drag is moving from upper left corner as the pivot , whereas i want it to move from center pivot


enter image description here

    public boolean onTouchEvent(MotionEvent ev) {

        switch (ev.getAction()) {

        case MotionEvent.ACTION_DOWN: {

            X = (int) ev.getX();
            Y = (int) ev.getY();


        case MotionEvent.ACTION_MOVE: {

            X = (int) ev.getX();
            Y = (int) ev.getY();


        case MotionEvent.ACTION_UP:


        return true;

    public void onDraw(Canvas canvas) {
        // draw background
        canvas.drawBitmap(bgr, 0, 0, null);
        // copy the default overlay into temporary overlay and punch a hole
        // in it
        c2.drawBitmap(overlayDefault, 0, 0, null); // exclude this line to
                                                    // show all as you draw

        c2.drawRoundRect(new RectF(X, Y, X+350, Y+350), (float)20.0, (float)20.0, pTouch);
        // draw the overlay over the background
        canvas.drawBitmap(overlay, 0, 0, null); 

I have added this UICollectionViewDelegate with my implementation:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
    SAPCollectionViewCell *collectionViewCell = (SAPCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"SAPCollectionViewCell" forIndexPath:indexPath];

    NSInteger index = indexPath.item + indexPath.section * 2;

    NSString *imagePath = [_images objectAtIndex:index];

    collectionViewCell.index = index;

    [collectionViewCell setImageWithPath:imagePath];

    collectionViewCell.delegateCell = self;

    return collectionViewCell;

In my custom cell I have this method:

- (void)setImageWithPath:(NSString *)imagePath
    if (!self.imageView)
        CGRect rect = self.contentView.frame;

        self.imageView = [[UIImageView alloc] initWithFrame:rect];

        [self.contentView addSubview:self.imageView];

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

            UIImage *image = [UIImage imageFromPath:imagePath];

            UIImage *resizedImage = [UIImage imageWithImage:image scaledToWidth:rect.size.width];

            dispatch_async(dispatch_get_main_queue(), ^{

                [self.imageView setImage:resizedImage];


So as you can see if the cell does not have UIImageView then I start to create it and in background I get image from local path and resize it to cell content view width, then in main queue I set image to UIImageView.

This part work good but when I try to scroll my UICollectionView e.g. with 10 images I noticed that for example if first 2 top images were disappeared when I scroll down and then when I scroll back to the top, the images are changed placed.

This is state of images before scrolling down:

enter image description here

And this state after I scroll UIColectionView back to the top:

enter image description here

So as you can see first to item changed theirs location. As I have set if (!self.imageView) in my code above it should means that the image never will be created twice or more times.

I opened debugger and was checking this method:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

So the images paths returned one by one as it worked when UICollectionView just created cells at first time.

At first time first UICollectionViewCell has 0x8fbc1d0 and second has 0x8d0a4c0 address

But when I scroll down and then scroll up the debugger shown me second address at first 0x8d0a4c0 and then shown me 0x8fbc1d0

But I can't understand why items change theirs order. Or maybe here is another issue?

Also I don't have any method in the code that make for example for me reorder for cell. just few UICollection view methods delegate that configure count of cells and create them.

Also if I remove if (!self.imageView) seems everything works good, but then my code every time invoke dispatch that's no good for me, because when I resize image to the cell size I don't need do it twice.

I have a floorplan that I need to turn into a tilemap. I'm using the program HD2x to convert my tilemap into an -hd tilemap. I tried it in different ways:

1)I converted the floorplan into a -hd .png with HD2x, and then put this into Tiled, and the saved it and converted the final .tmx file into -hd. I then put the -hd tmx and -hd png file into x-code.

2)I put the regular floorplan into tmx, and then converted this into -hd and converted the floorplan.png into -hd, then put these into x-code.

These aren't working.. either the tilemap is half the size it should be, or it's a QUARTER of the size it should be and the floorplan looks messed up.

Please help.

I am trying to Animate the transition of a UITableViewCell when its height is changed. For this I am using the following lines of code:

    [meetingsTable beginUpdates];
    [meetingsTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:changedRow inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
    [meetingsTable endUpdates];

but it is not showing the row height change animation. It just displays the expanded cell. However, if I remove the line

[meetingsTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:changedRow inSection:0]] withRowAnimation:UITableViewRowAnimationNone];

it shows the expected animated height change but the cell is not reloaded. I have tried all the available UITableViewRowAnimationoptions but with no success. I have also tried

[meetingsTable reloadData];

but it is also not helpful. Please suggest what can be the possible solution.

I am creating two TextFields dynamically and adding them the EditingChanged event like in the following example

import UIKit

var view:UIView = UIView()

let inp1:UITextField = UITextField(frame: CGRect(x: 20, y: 0, width: 100, height: 44))

inp1.addTarget(view, action:  "text_updated", forControlEvents: UIControlEvents.EditingChanged)

let inp2:UITextField = UITextField(frame: CGRect(x: 20, y: 50, width: 100, height: 44))

inp2.addTarget(view, action:  "text_updated", forControlEvents: UIControlEvents.EditingChanged)


func text_updated(){
    println("who has called me?")

As it is there is no way to know which one of the controls has called the text_updated function.

When I pass the TextField as a parameter

func text_updated(sender: UITextField) {


I get an "unrecognized selector sent to instance" exception.

How is it possible to know which TextField was changed?

I want to make an extension for my iOS 8 app (preferably an action extension, but a share extension would do the job as well).
And I want this extension to be accessible from iTunes so my users could send an iTunes link to my app.
But I just can't figure out how to make this extension available from iTunes (and only from iTunes by the way).
I have tried NSExtensionActivationRule.NSExtensionActivationSupportsWebURLWithMaxCount, but it only activated my extension from Safari, not from iTunes.
I wonder if there could be a way to do it with a predicate, but I can't figure out how to build a predicate that can detect an iTunes "element/link" (for lack of a better term).
Does someone have a solution for that ?

I am using a variety of these commands to navigate my app:

NavigationController.PushViewController( ... );
NavigationController.PopViewControllerAnimated( ... );

In my app it's possible wander around and get a bit deep in pushed view controllers. I want to popup a message when they get more than 15-20 levels deep. I can add my own counter, but is there a way to determine the depth of the Navigation Controller's stack?

is possible when a call is executed from telprompt, hide the phone call has to be different and show another user en objective c

NSString *phoneNumber = [@"telprompt://" stringByAppendingString:strNumber];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];

i have been busting my brain trying to figure out how this works, but i can't seem to get it. i have tried using other tutorials, but with the many beta releases, everything keeps changing. i am fairly new to IOS development, so i'm kind of struggling.

in storyboard i have UITableView, which contains a cell with the identifier "myCell".

here's what i have so far. when i run the IOS simulator, nothing is presented on the table view.

any suggestions on how to fix this?

class ViewController: UITableViewController {
  override func viewDidLoad() {
  override func didReceiveMemoryWarning() {
  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
     var cell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath) as UITableViewCell
     cell.textLabel?.text = "Cell #: \(indexPath.row)" // display the row number
     return cell
  override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
     return 10; // testing out with 10 cells

How to declare function that takes generic type that conform to “can be multiplied” in Swift ?

For example :

 func sq <T: "Can be multipied">(x: T) -> T {
    return x*x

So that I could square Float, Double, CGFloat etc ... It this possible at all ?

This question already has an answer here:

I am working on an iOS app, using web-service. For call my web-service i decided to use AFNetWorking 2.0. And i have a big issue : On the command line i use curl :

    curl -X POST -d '[{"username":"user123","password":"querty"}]' -H "Content-Type:          application/json" http://mysite

This works perfectly.

Now when i want to use on iOS App:

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    manager.requestSerializer = [AFHTTPRequestSerializer serializer];

    [manager.requestSerializer setValue:@"application/json; text/html" forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:@"application/json; text/html; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    NSDictionary *parameters = @{@"username": @"user123", @"password":@"querty"};

    [manager POST:@"http://mysite" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"JSON: %@", responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);

i got this error : Request failed: unacceptable content-type: text/html

I'm trying change background color of UIView. here is my code:

UIView *myView = [self.view viewWithTag:21];
[self.view bringSubviewToFront:viewToChange];
myView.backgroundColor = [UIColor yellowColor];

I verified :

if ([myView.backgroundColor isEqual:[UIColor yellowColor]])
        NSLog(@"my view is yellow!");

but in the screen of the iPhone never change colors. I tried the same code in different project and it works just fine. Any of you knows what can be wrong?

Problem with Whatsapp..I dont know why I am not getting whatsapp push message service from version 4.9.14

I have just completed my first WCF REST api that makes use of JSon for posting data back to a client app. As part of the dev process I made a quick sample c# forms app for testing. I serialize the incoming Json response and bind to gridview. An example would be of retrieving Balances for the associated ID's of accounts. I have yet to host this, but the idea is to host it on a client server, and for them to be able to develop 3rd party apps.

I really really want to develop a simple sample Windows Phone or Android app, for showcasing as well as learning how to access this hosted service. I have found plenty of articles on accessing via being connected to wifi. But, say I want to develop an app and distribute this on an app store. For users connecting via mobile connection, say 4G, how would this be achieved? If I host via IIS on a server, would I be able to use the URL in a client Android/Windows phone etc. app, authenticate via an API key and retrieve the data?

Please can someone advise on how to go about or where to start please?

Thanks in advance.

I have some experience with NoSQL (MongoDB and CouchDB) and I am interested in exploring wide column databases.

Based on my initial exploration I can grasp a basic understanding of how wide column stores are different, but I do not really understand in which type of operations they are a better fit than an indexed document store.

My initial impression is that column stores are better if the column combinations for the queries are highly dynamic (no indexed view really required) and/or if there is a high rate of writing (that triggers map-reduce indexes in a document store).

Performance wise, it seems that column stores might be better if I have documents with many properties but not all of them are needed. Document stores seems to promote that the whole document will be retrieved, but not sure how much impact this really has. Maybe the document needs to have many filtered columns to make a difference?

Also I got the impresion that column stores "might" be more performant for multi-tenant systems which shared database where one of the columns holds the tenant id and maybe another one the roles.

In which type of queries wide column stores are a better fit against document stores?

Are both of them equally good for horizontal growth?

UPDATE: After reading my own question, I am getting the feeling that wide column stores are very good for the queries done by data analysis applications, while document stores are already good enough for the most common consumer oriented applications.

I've been looking for a way to get into programming for about a year now. I have about 2 years experience with scripting and programming at home and have been working for an 'IT' company for nearly 2 years. I say IT company loosely. They are an IT company but literally anybody could do the job.

My trouble is finding a job without any professional experience (I'm sure most people can relate to this). I've had several interviews this year for help desk roles and devops roles all with the same outcome, "you are good but we need someone with more professional experience". I'm about to apply for a junior software engineering role but want to do things a little differently. I am rubbish at lying and far too honest when it comes to interviews. But I feel like I am needing to lie about my current job to include the things I do at home.

I know I can do the jobs I'm applying for, but with no relevant education or proper experience I'm finding it impossible to prove I can do what they need me to do. I recently set up a website which I'm using as a platform to present my work and what I'm doing. I've not really had a chance to show it off to any potential employers yet though.

I will definitely work in software development one day and I have no doubts about that because I am so determined. I just want to know if its OK to lie to take a short-cut.

In short my question is. Is it OK to lie about what you do at work in an interview as long as you know you are capable of doing it.

I've also been looking at going back into education for something computer science related. I already have a degree in Structural Engineering so it's not a decision I want to take lightly considering I'd have to fund it myself, but if it was going to get me a job then I would definitely think it would be worth while.

P.S. references aren't a problem for me.

This question came up in one of my college classes. The professor only gave the answer that it was more descriptive, but it seems as though < b >and < i > are rather explicit in their meaning and is easier to type than < strong > and < em >.

What were the official arguments for the deprecation of these tags?

Might be a silly question... but per this page: it would be helpful to VAC if you can provide them binaries of the cheating programs. I stay up to date on because I want to eventually do some work in security, and I noticed they have counterstrike section. There's literally dozens and dozens of private small cheats there and I want to help contribute to getting them banned. All these cheats are external. Is it possible to get the binaries of an external cheat?

I'm building a multi-tier enterprise application using Spring. I have different layers: Controller, Business and Provider. Within the application I've built a custom error handling mini-framework that is based on a single RuntimeException which has an error code to discriminate different kind of errors.

Error codes are enums implementing this interface:

public interface ErrorCode {
    public int getNumber();
    public String getDeveloperMessage();
    public String getHelpURL();
    public boolean isSystemError();

So for example I have:

public enum SystemErrorCode implements ErrorCode{
    E_UNKNOWN_ERROR(10000, "Unkwown internal error", true),
    E_MISSING_ARGUMENT(10001, "Missing argument", true),
    E_INVALID_ARGUMENT(10002, "Invalid argument", true),
    E_CONTEXT_NO_TENANT(10003, "No tenant in context", true),
    E_CONTEXT_TENANT_CHANGE(10004, "Tenant change attempt", true),
    E_CONTEXT_ALREADY_INITIALIZED(10005, "Tenant already initialized", true),
    E_NOT_IMPLEMENTED(10005, "Feature not implemented", true),

The exception class itself look like this (getters, constructors, and utility methods are stripped out for brevity):

public class EngineRuntimeException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private final String incidentReportId;
    private final ErrorCode code;
    private final Map<String, Object> additionalInfo;


    public static EngineRuntimeException wrap(Throwable exception, ErrorCode errorCode) {
        if(exception instanceof EngineRuntimeException) {
            EngineRuntimeException se = (EngineRuntimeException)exception;
            if(errorCode != null && errorCode != se.getCode()) {
                return new EngineRuntimeException(exception.getMessage(), exception, errorCode);
            return se;
        } else {
            return new EngineRuntimeException(exception.getMessage(), exception, errorCode);

    public static EngineRuntimeException wrap(Throwable exception) {
        return wrap(exception, SystemErrorCode.E_UNKNOWN_ERROR);

Using the wrap utility method I can easily encapsulate exceptions in the different layers without loosing the original stack and without having it dirty by rethrowing or incapsulating exception more than once.

try {
  if(a == null) {
    throw new EngineRuntimeException(SystemErrorCode.E_UNKNOWN_ERROR, "blah, blah, blah");

  // Some other code that can throw exceptions (checked or unchecked),
  // these exceptions will be wrapped inside EngineRuntimeException if they
  // are not already of that type.

} catch (Exception ex) {
    throw EngineRuntimeException.wrap(ex);

To recap, each layer has a safety boundary try-catch that wraps Exceptions into EngineRuntimeException, just rethrowing what is already an EngineRuntimeException.

The question is: where should I log the exception? I want to log the exception only once so I was thinking about do the logging stuff inside the constructor of EngineRuntimeException class itself. Is that a bad idea? Is it better to do the logging stuff only in the catch blocks of the layer boundaries?

Also I don't want to simply log using a log4j but I want to use a service (@Service) injected by spring so that I can decide to do something more than just logging on file system. How can I do that since I can't make spring inject something in a class I have created with the "new" instruction.