Monday, September 9, 2013

[android help] Eclipse Android (ADT) How do I use methods from other classes in MainActivity class?


Eclipse Android (ADT) How do I use methods from other classes in MainActivity class?



Classes A, B and C is located only in src and the MainActivity.class in source/com/example/TestApplication.


MainActivity doesnt seem to see the other classes because they are not located in the same location/package. How can I call the other classes' methods to work in MainActivity.


Here is an example of my code: I want to run UseActivity methods in MainActivity



public class UseActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public String sEntries(View view)
{
DatabaseHandler db = new DatabaseHandler(this);
String sfinal = "";

// Inserting Contacts
Log.d("Insert: ", "Inserting ..");
db.addContact(new Contact("Ravi", "9100000000"));
db.addContact(new Contact("Srinivas", "9199999999"));
db.addContact(new Contact("Tommy", "9522222222"));
db.addContact(new Contact("Karthik", "9533333333"));
switch (view.getId())
{
case R.id.button1:
EditText dbText = (EditText) findViewById(R.id.editText1);

// Reading all contacts
Log.d("Reading: ", "Reading all contacts..");
List contacts = db.getAllContacts();
for (Contact cn : contacts)
{
sfinal = "Id: "+cn.getID()+" ,Name: " + cn.getName() + " ,Phone: " + cn.getPhoneNumber();
// Writing Contacts to sfinal
Log.d("Name: ", sfinal);
dbText.setText(sfinal);
}
break;
}
return sfinal;
}
}



public class MainActivity extends Activity
{

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

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

UseActivity u = new UseActivity();
{
u.sEntries(View view);
} /////////////////////////// this doesnt work, program underlines UseActivity in red giving error and doesnt see it as another class (maybe because of package)


Read more

stackoverflow.comm



[android help] why bluetooth chat is not working properly?


why bluetooth chat is not working properly?


android - why bluetooth chat is not working properly? - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















when i connect first time via bluetooth i can send sms ..but if i disconnect then again connect with anyone keeping bluetooth on i couldn't send sms though i could connect with that device..but if i trun off bluetooth and again turn on it and connect with some one then i could send sms...is there any problem with my onStop() and onDestroy() method??do i have to use onFinish() method????



@Override
public void onStop() {
super.onStop();
if(D) Log.e(TAG, "-- ON STOP --");
}

@Override
public void onDestroy() {
super.onDestroy();
// Stop the Bluetooth chat services
if (mChatService != null) mChatService.stop();
if(D) Log.e(TAG, "--- ON DESTROY ---");
}

//here is my full code of bluetooth chat class
http://paste.ubuntu.com/6082004/


















default






Read more

stackoverflow.comm



[android help] onBackPressed method showing for less than a second


onBackPressed method showing for less than a second


android - onBackPressed method showing for less than a second - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
















I am using the above method to create something like an exit dialog for my application. The code works just fine but the alert dialog box only stays on screen for less than a second. Then it dissapears and the application closes without following my instructions. I have no idea why this is happening.


Thank you guyz in advance.



@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();

DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
ganthem.stop();
System.exit(0);
break;

case DialogInterface.BUTTON_NEGATIVE:

dialog.cancel();

break;
}
}
};

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Exit or not ?").setPositiveButton("Yes", dialogClickListener)
.setNegativeButton("No", dialogClickListener).show();
}




























Remove super.onBackPressed();.




















default






Read more

stackoverflow.comm



[android help] opengl es 2.0 mysterious white lines at textures left side


opengl es 2.0 mysterious white lines at textures left side



I am working on an Android platformer game using opengl es 2.0. I created an "engine," or more like a frame that handles most of the opengl stuff. Similar to Unity, the game elements are game objects - there are components like animations, images, route finding etc.


The problem is that I draw out squares that represents the ground with red and another element with blue which is the player. I moved the squares up on y axis so you can see them. Each square is a simple flat built up from two triangles and each has a plain red texture using from a .png file.


You can view a screenshot here: http://www.themobius.hu/white_line.png


So the problem is that white line at the left side of the 6th square. If I move the player in any direction it disappears and appears for "random" other squares.


If I remove the textures and only color the squares than the lines disappear so it has to do something with the texture.


Tried other textures and for this exact float position it always appears.


Now the squares are overlapping each other but only to reproduce the error. If I place them perfectly it only happens when the float value accuracy makes them overlapping a bit.


The line is always white. I changed the background to a different color to be sure.


I haven't added any code here because there is lot of code involved and for now I assume that this is an common opengl engine problem and I don't know what it's called.



Read more

stackoverflow.comm



[android help] OpenGL and OpenGL ES performance comparison


OpenGL and OpenGL ES performance comparison


android - OpenGL and OpenGL ES performance comparison - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
















I am buying the new Nexus 7 tablet and recently started learning some OpenGL so in few days I will be able to test OpenGL ES too.


As I understand it, many functions in ES are the same as in desktop OpenGL. So my question is, when I write the same application for both PC and Android device, using only ES supported methods, is the performance comparable? I mean I build the same SDL+OpenGL app for both android and on notebook, rendering the same graphics (on same resolution probably) can I compare the FPS and say how much faster my PC is, or does OpenGL ES work somehow else then normal one and therefor the results cant be compared?





























You cannot compare OpenGL and ES version.


First thing is that they will run on different OS (like Windows vs Android) and what is more important they will run on different GPU with different architecture. Too many factors to check.


You could compare different Android implementations for instance...




















default






Read more

stackoverflow.comm



[android help] Is there an onBackPressed() alternative for a service?


Is there an onBackPressed() alternative for a service?



I know that services cannot implement Back key press and I understand the rationale. But there is an app called SideBar (on Play Store) that reacts to back key presses. It is a service that adds a view as system overlay and removes the view when the back key is pressed. Can anybody explain how this is done?



Read more

stackoverflow.comm



Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...