peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Good article, but I would suggest to rename some of imageViewas it is not good practice to have multiple of same name in the the project ;)

dimitrilc commented: Thanks for the reminder. There is only one imageView View in this project though? +1
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@rproffitt @Naheedmir sorry guys but you failed for cheapest trick in online spam.

OP did not really cared about development outsourcing, cons and pros. He just wanted to use his signature that goes to "drums roll" ta-da to some outsourcing company. Classic forum link click advertising. Few years back this would be deleted, not sure about recent rules... Looks like signature link is OK

rproffitt commented: Dani wrote it was OK. Why? Log out and you don't see the tagline as well as it's not seen by SEO robots. +15
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

The idea of testing your code is to have some method that has a return and that is what you want to test. So to get testing going on above code you would have to change return type to String

public String methodToCheckStr(int testVar)
    {
        String str="";
        if(testVar==5)
        {
             return "Success";
        }
        else
        {
            return "fail";
        }
    }

And then you can have tests as

@Test
public void testSuccess() {
   StringChecker checker = new StringChecker();
   assertEquals("Success", checker.methodToCheckStr(5));
}

@Test
public void testFail() 
   StringChecker checker = new StringChecker();
   assertEquals("fail", checker.methodToCheckStr(4));
}
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There are cross-platform tools like Titanium(C#), Cordova(HTML5 and jQuery). Also possible with Python, Scala or Kotlin. However these will be always slower than native implementation...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@Slavi Eclipse usage is discouraged as Android Studio is these days prefered and reccomended tool even by Google. Eclipse Gradle implementation lags behind AS and it will be evntually dropped https://developer.android.com/sdk/index.html

As for your question @serenagrace this is what you need

  1. Knowledge of Java and basics of XML
  2. Installation of Java SDK 7 (8 and higher is not recommended as Android is not fully compatible).
  3. Android Studio, 1.3 is latest

Optional

  • Android SDK download - you will get one with Android Studio but I prefer a copy that I'm in control in regards of location of instalation
  • Stand alone installation of Gradle download - you may stick with Gradle wrapper provided by default by Android Studio wizard it will do all
  • Genymotion download - a faster emulator than the one that is part of Android SDK. Provided link is to free version. See comparision between free and busines copy here https://www.genymotion.com/#!/store
Slavi commented: Ah, gotcha! (Been awhile since I left Android world =[) +6
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Is it so hard to use Google search these days???? "java itext create hyperlink" and first link is http://itextpdf.com/examples/iia.php?id=131

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Take my advise and use ActiveAndroid library or it new brother Ollie Simple object to object transactions, no need to SQLite boilerplate.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You are misunderstanding concept. This is not jar library that you add to your project, but rather expectation that user has this application installed on device and thereore with help of Android intent you can say "load this url with following application of this package name"

OsaMasw commented: thanks +2
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There is no official API yet as this is still under development. However according to VLC forum you just need to do this

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("org.videolan.vlc.betav7neon"); // Use org.videolan.vlc for nightly builds
intent.setDataAndType(Uri.parse("http://example.com/media/test.mp4"), "application/mp4");
startActivity(intent);

My suggestion would be to check first for vlc in PackageManager to avoid crash if app not installed. You can follow discussion on intent here

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Without seeing actual code hard to say...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Hard to judge what would be the targeted areas for improvements. Do you have any open source project we can have look?

Otherwise I would ask how confident you are with collectable, what sort of components/librarues you are using for networking, json parsing, image handling.
Did you do any code testing? JUnit, Mockito, Espresso, Robolectric, Instrumentation, UIAutomator, Monkey

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Ahhh, OK. Simple, lets examine code (sorry for cheeky comments)

if(new File("ATM.xls").exists()){ //check if file exists
    System.out.println("File exists"); //YES it does exist
    //but I failed to assigned to some object
}
else{
    File excel = new File("ATM.xls");//doesn't exist so I create new file
    //but this go no further because it is local variable
}

So the code should be something like

File excel = new File("ATM.xls");
if(!excel.exists()) {
    try {
        excel.createNewFile();
    } catch(IOException e) {
        Systemout.println("Failed to create new file, \n" + e.getMessage()); //Log framework would be much better instead of system print outs
}
//I have made sure file either exists or is created and now I can continue
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@Dave he did but post it as code instead of simple text

@sabata mmoledi forum rules clear state Do provide evidence of having done some work yourself if posting questions from school or work assignments so time to show some effort we are not your coding monkeys

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You aware that Android and iPhones ditched support for Adobe Flash

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Daniweb rules says

Do provide evidence of having done some work yourself if posting questions from school or work assignments

So post what you wrote so far and maybe will help you

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Daniweb rules says

Do provide evidence of having done some work yourself if posting questions from school or work assignments

So post what you wrote so far and maybe will help you

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You need to run your music as servive, you can see example here http://developer.android.com/guide/topics/media/mediaplayer.html#mpandservices

jalpesh_007 commented: thanks.it is helpful. +4
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
ravi142 commented: @Thank you +2
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Not working is rather bad description. If you post any error/crashes you gettng perhaps someone may help you...

Jimmy Gim commented: same feeling with you +0
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Spring develeopers produceded documentation with official tutorials http://docs.spring.io/spring/docs/current/spring-framework-reference/html/index.html

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry I never did this with POI.Given that so far nobody provided usable answer you may want to try their mailing list and ask directly contributors http://poi.apache.org/mailinglists.html

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Link here

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@Slavi not exactly, question is how to get XSSFDrawing or XSSFPicture to some stream format that can be used to create image.

You should spent little more time reading question and have look on code, API before calling generic search for Java code ;)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Time is Android represented either by Date or Time objects. Each of these will return result in miliseconds as long variable (http://developer.android.com/reference/java/util/Date.html#getTime() http://developer.android.com/reference/android/text/format/Time.html#toMillis(boolean) ). Then you just need to compare time1 to time2 to find if it is lesser/equal/greater

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This is how simple it can be done

Button one = (Button)this.findViewById(R.id.button1);
final MediaPlayer mp = MediaPlayer.create(this, R.raw.soho);
one.setOnClickListener(new OnClickListener(){

    public void onClick(View v) {
        mp.start();
    }
});
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If i read it correctly your insertValue R.id.txtInsert is part of R.layout.add_item. If that is case then

final EditText insertValue = (EditText)findViewById(R.id.txtInsert);

will be null because edit text was not found. You have to find it in coresponding view, so it should be like

final EditText insertValue = (EditText) addView.findViewById(R.id.txtInsert);
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You need to know Java, if you don't then go and learn it then come back.

If you know Java, then perhaps reading one of these books will be suficient enough

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You failed to specify what operaring system you want to develop for ANdroid or iOS...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Never tried to do such think. However I found this post on stackoverflow that discusses extracting data from current connection. So based on that I looked up ServiceState and that has getOperatorAlphaLong() methd that according documentation

Get current registered operator name in long alphanumeric format.

So you are able to discover your current provider. Question is if you can trigger call for discovery of all available networks...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

List followed by code snippet does not render properly. Example

  • Item One
  • Item Two
  • Item Three

    Log.i(MainActivity.class().getSimpleName(), SOME_MESSAGE); //info
    Log.d(MainActivity.class().getSimpleName(), SOME_MESSAGE); //debug
    Log.w(MainActivity.class().getSimpleName(), SOME_MESSAGE); //warning
    Log.e(MainActivity.class().getSimpleName(), SOME_MESSAGE); //error

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Here is update, I added some comments in code and also at the end of post

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import co.uk.apptivation.nga.library.R;

import java.math.BigDecimal;

public class MainActivity extends FragmentActivity { //FragmentActivity is preferred over ActionBarActivity very few apps supports 7 and bellow

    private TextView textview;
    private Globals globals;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textview = (TextView) findViewById(R.id.textView);
        globals = Globals.getInstance();
    }

    /* Function handles event when a number button is pressed */
    /* Including decimal point */
    public void numberPressed(View view) {

        Button button = (Button)view;
        textview.append(button.getText().toString());
    }

    /* Function handles event when "+" button is pressed */
    public void addPressed(View view) {
        //Global now available as class variable no need for creating it
        //Textview now available as class variables
        BigDecimal bd = new BigDecimal(textview.getText().toString());
        globals.setData(bd);
        globals.setlastoperation(1);
        textview.setText("");
        //no need to set local variables to null JVM garbage collector takes care of this
    }

    /* Function handles event when "=" button is pressed */
    public void equPressed(View view) {

        //Global now available as class variable no need for creating it
        //Textview now available as class variables
        int lasTop = globals.getlastoperation();
        BigDecimal bdg = new BigDecimal(globals.getData().toString());
        BigDecimal bd = new BigDecimal(textview.getText().toString());
        switch (lasTop) {
        case 1: {/* "+" button was the last operator button pressed*/
            BigDecimal sum = new BigDecimal(bdg.add(bd).toString());
            textview.setText(sum.toString());
            break; //do not forget to add break otherwise you may for get with next case and your process will felt through case 1 to case 2
        }
        default:
            //May want to …
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Back to layouts, here is something you maybe interested in to read https://plus.google.com/+AndroidDevelopers/posts/FJv7Pym2HtZ

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Check what is maximum of RAM you can add to your PC. RAM these days is not very expensive and in this case worth upgrade. Company like Crucial can help you with hardware detection and potential memory upgrades

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Yes difference been them is down to screen sizes, you would need to provide layouts for mdpi, hdpi etc. which do provide different sizes of buttons, fonts, spacing and other

  1. It is good to have at least 8GB RAM so you can assigned more memory to emulator then 128MB that it will get by default
  2. Give emulator more power, I use following on emulator for Nexus 4 Target: 4.1.2, CPU/ABI: Intel Atom (x86), Memory options RAM: 2048, VM Heap: 1024
  3. Unfortunately Android SDK or ADT doesn't have latest Intel® Hardware Accelerated Execution Manager, but you can get it here https://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager
  4. It is always better to test on real device, Motorola Moto G is as little as £120, also Nexus 7 is very cheap, and for 10" Asus Memo pads are great value for the money. You do not need all these gadgets but one real device makes hell of difference
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

GridLayout takes a collection of items. So you need to design layout of a singular item. Then you create adapter, tell it to use your item layout, provide and provide collection of data you want to populate your grid with. You can read on it here http://developer.android.com/guide/topics/ui/layout/gridview.html

BTW, if I can recommend it is better to learn hands about each view and code by hand at beginning and use UI builder later when you know what the component is expecting and what it will do for you.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Android Studio is becoming industry standart with better features then Eclipse

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Any website is accessible by mobile devices these days. You just need to learn restrictions and serve appropriate content, therefore browser and operating system detection is important

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Then you should not posted at all because if they never learn basic they will fail. It is OK to help with attempt when someone tried and got catch in some circumstances that may not be obvious. However provide solution beforehand is plain bad.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
  1. Increase quality of the app, fix crashes and bugs
  2. Implement functionality requested by users
  3. Interact with people that commented on app
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry to say, but hardly anyine does Android development on Windows machines down to various issues with configuration. Secondly Eclipse is such mess.

Try to isntall Android SDK from zip instead of automated installation (do not forget to modify your system path and ANDROID_HOME there). Aso I would recommend to use AndroidStudio or IntelliJ.

PS: I hope you have Java 6 32 bit installed and not something else

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You can use either Android provided JSON capabilities (little cruel and long winded) or you can use any of number of open source libraries like Gson, Jackson that let you easily parse json to specific class

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You may consider using JSOUP library for parsing html. Better then doing "by hand"

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@bCubed you sure your link is valuable?

Learn Java Tutorial 1.4- Using the while loop to bark for awhile..

I would call it way out of date given Java 6 is slowly replaced by Java 7 and Java 8 is just behind corner

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@cool_zephyr I will say it is everyone personal opinion/preference how to proceed. Because as to your recommendation I can say "why to bother with file read/write logic when there is already database connectivity?"

@CoilFyzx it is difficult to give deceisive answer without knowing more about functionality of your application.

1st point, as ong there is no heavy data processing (thousands of entries to go through before displaying result, which means delay before user sees anything) you more then safe to do it on each read

2nd point, you may create special table to hold data of last seen UI, simple if working with single UI view (school assignmen). However that may be impractical if you have multiple UIs you will require number of such tables.

For 3rd point implementation is really up to you if you want to keep config file or database config table, same goes for credentials

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Just for benefits of community here is sample

{name: "peter_budo", userGroup: ["user", "moderator"]}

For this you would require class something like this

public class User {
    @SerializedName("name")
    private String name;
    @SerializedName("userGroup")
    private List<String> userGroups = new ArrayList<String>();

    public String getName() {
        return name;
    }

    public List<String> getUserGroups() {
        return userGroups;
    }
}

JSON will come over HttpClient or similar as a String. In order to get it converted to Java object you have to first parse string to get JsonObject and after it with help Gson class you can cast it to your class type

private User parseJson(String json) {
    JsonParser parser = new JsonParser();
    JsonObject userJson = parser.parse(json).getAsJsonObject();
    Gson gson = new Gson();
    User user = gson.fromJson(userJson, User.class);
    return user;
}
~s.o.s~ commented: Upvote for the benefit of Peter ;) +14
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Given that 5 years ago I written [JSP database connectivity according to Model View Controller (MVC) Model 2] (http://www.daniweb.com/web-development/jsp/threads/141776/jsp-database-connectivity-according-to-model-view-controller-mvc-model-2)tutorial that sits on top of the JSP section it still amazes me that people are putting connectivity inside of JSP and making mess of such basic task

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@asif49 PhoneGap, you just made me cry. You should really use native code not some framework that is trying to emulated native environment. It never gone be on same technical level

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You can always create zip file, download it when dedicated directory not existent on phone system. You should also look up some image loader library like Novoda ImageLoader to help you with image fetching from resources

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

no I said use on onResume() because onCreate is only executed when activity or fragment is started for first time, but it is not executed when coming back from pause state that mean user moved on different activity or fragment and then he decide to press back button, or perhaps your application was pause down to call or received SMS and user does return back to it and application is started from last know state and that state start with resume. Read on Activity lifecycle here