Friday, April 26, 2013

[android help] How do I use Intents with ListView?


I know there are many solutions to solve this problem.


But it's not same case as that.


This is my java code.



package com.progme.sejong_bus;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class BUSActivity extends Activity {

ListView listView;

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

String []data =
{"공통공지사항","101번 버스정보","102번 버스정보","103번 버스정보","104번 버스정보",
"105번 버스정보","106번 버스정보","107번 버스정보","108번 버스정보","109번 버스정보",
"110번 버스정보","111번 버스정보","112번 버스정보","113번 버스정보","114번 버스정보",
"115번 버스정보","116번 버스정보","117번 버스정보"};

listView = (ListView)findViewById(R.id.listview1);

ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, data);

listView.setAdapter(adapter);
}
}


and this is my XML code




xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#000000" >

android:id="@+id/listview1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="top"
android:layout_weight="1"
android:cacheColorHint="#000000"
android:dividerHeight="1dp"
android:divider="#FFFFFF" >






I want intent to each list.. but how can i select each list?


And what code that i have to use?



.

stackoverflow.comm

[android help] activity is gone and the created handler is still in use

android - activity is gone and the created handler is still in use - 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.

















An Activity created a handler in a method and passed it on to a singleton. Singleton holds this handler so that it can send the message back to activity. Activity handles the message in that local method by implementing the handleMessage(Message mesg) methond.


What happens if the activity gets destroyed and singleton tries to send the message via the handler.


























Once handler starts it does not stop.


Try AsyncTask it may be canceled or interrupted.




















default






.

stackoverflow.comm

[General] New Icon?


In the future, if there is an icon you are unsure of, your phone comes with an icon glossary. Settings> about> help> icons :-)

Sent from my Verizon Droid DNA



.

forum.xda-developers.com

[General] Help, New apps downloading from playstore themselves every night...


I can only assume my daughter clicked on some link while playing Paplinko.
That or subway surfer were the only ad intense apps I had.

Now every night my phone downloads 1 new app directly from the play store.
They even show up on my apps list when I log onto the play store from my computer at home.

Recent unwanted downloads.
Gnome Village-Disney
iTriage-itriage llc
Slotomania-Playtika

I deleted the others.

Anyway I've run just about every antivirus and ad detector in the play store, they all find nothing.
I've factory reset the phone 4 or 5 times and it is still happening.
Removed the memory card and then factory reset but did not reinstall the card. . Still happening.
FDR from the recovery menu nothing helps.

I searched on line but can not find anyone with the same issue. All the apps that have down loaded have good reviews at least. )

No other issues. No web redirects, no short cuts on desktop leading to 3rd party sites.
Everything is normal except for the new app each morning.

Right now the only apps I have legitimately downloaded are:
Tune in radio (paid)
Shush
Snap speed
Alarm clock plus (paid)
Business Calendar free.

I may get a new phone but I'm trying to figure out what this is and if Google or the Play store will
Reload something that is attached to my account when I get the new phone.

Thank for any help you can provide.



.

forum.xda-developers.com

[General] Possibly a stupid question ? (SGS4)


Not a stupid question at all. Give TW a try. I didn't find using it on my S3 to be an issue, but ended up switching to Nova because of a bug impacting the Lightflow app when used with TW. I wasn't willing to give up LF, so I switched launchers.

Anyway, I suspect at least some of them will still work. The Samsung motion add-ons in the S3, for example, continue to work with Nova. Page Buddy, OTOH, only works with TW. If you decide to get rid of TW, I think you'll have to try them out, one by one, to see what works and what doesn't.



.

forum.xda-developers.com

[General] Help! What is this calendar widget?


Actually, I think I know what happened. I think the image you posted is the old stock Calendar widget from Ice Cream Sandwich. When we got the Jellybean update, the stock Calendar widget changed such that it can only be as small as 2x3.

You should still have the Calendar widget available to place on a home screen. Do you not see it in your Widgets list?

Sent from my DROID RAZR using Android Central Forums



.

forum.xda-developers.com

[General] Pinpoint AlarmManager Wakelocks?


So I've noticed that my phone pretty much never sleeps, and the battery drain is substantial. I installed Wakelock Detector and have narrowed the culprit down to the AlarmManager service in the Android System. I understand that this service itself is not the problem as it's simply used by other apps to keep the phone awake, but I have no way of narrowing down which apps are triggering the alarms. I understand it's possible by running sysdump alarm > file.txt from the terminal, but I've tried that and realized this requires root privilege, which I don't have. I'm at a complete loss as to how to nail the problematic app, so any help is greatly appreciated. Thanks in advance.



.

forum.xda-developers.com

[General] How to get notified of a thread when someone posts on it?


Sometimes when I make a post I have to go to the category and then the thread and then refresh to see if someone posted it. My question is, is there a way to get notified by email or here that someone posted? I tried "subscribing" but that doesn't work. Can anyone help me?



.

forum.xda-developers.com

[android help] Google maps marker show only icon


I want to display markers on google maps (android)


I used this code (like in the example in android developer):


The location, name and descripion are valid (I checked them via debug mode)


It shows me the icon on the desired location, however without the marker or the description and snippets. The following line



mMap.addMarker(MarkerOptions().position(location)
.title(poi.getName()).snippet(poi.getDescription())
.icon(BitmapDescriptorFactory.fromBitmap(image_item));


shows me only the icon without the title or snippest.


Thanks a lot



.

stackoverflow.comm

[General] Tried to copy all music files on my phone directly in to google music app.... They all disappeared


It doesn't really work that way. If you have a bunch of music files on your phone that are separate from Google Music, the best thing to do is to copy them to your desktop or laptop, install the Google Music Manager program, and upload all of your music to Google Music in the cloud. This will then sync with your phone's Google Music app, and you'll be able to stream your music from the cloud, or temporarily download some tracks.

Are you saying you copied or moved all of your music files into that com.google.android.music folder? If you copied them, they should still be present in their original location. If you moved them, I'm not sure why they would suddenly disappear. Use a good file manager app like ES File Explorer or Total Commander to search for your music files.



.

forum.xda-developers.com

[android help] How to set dyanamic generated textview's background on clicking


How to set backgroound drawable, when clicking a dyanamic created button like this :


enter image description here


I am using above code to create dyanamic button and track click of specific button :


for (int i = 1; i<8; i++) {



if(i==7)
{
btn = custom.myButton(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT), null, i+30, "...");
btn.setTag(i);
linear_paging.addView(btn);
}
else
{
btn = custom.myButton(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT), null, i+30, ""+i);
btn.setTag(i);
linear_paging.addView(btn);
}


btn.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

Toast.makeText(Earned_New.this, v.getTag()+" clicked", Toast.LENGTH_SHORT).show();
v.setBackgroundDrawable(getResources().getDrawable(R.drawable.black_rounded_background));
}
});
}


.

stackoverflow.comm

[android help] Android - sharing


Maybe you wanted a more complete answer because the accepted one was rather short, I'm a year too late but hopefully it's still useful :)


So here's a possible solution in handling multiple intents...


1) You want to know the result (eg succes or fail) of the intent?


Just start the intent using following line:



startActivityForResult(intent, 1); //instead of startActivity(intent)


And retrieve the requestCode and resultCode by overriding onActivityResult:



@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 0) {
if(resultCode == Activity.RESULT_OK){
//intent 0 = succesful (Facebook)
} else{
//intent 0 = failed or canceled
}
} else if (requestCode == 1) {
if(resultCode == Activity.RESULT_OK){
//intent 1 = succesful (Twitter)
} else{
//intent 1 = failed or canceled
}
}
}


2) You want to know which app the intent opened?


Don' trust the built-in intent chooser, make your own dialog and give each intent another requestCode (a unique integer-value, to identify the intent)


An example:



new AlertDialog.Builder(this)
.setTitle("Share with friends!")
.setSingleChoiceItems(new ArrayAdapter(this, android.R.layout.select_dialog_singlechoice,
new String[]{"Facebook", "Twitter"}), -1, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
StartFacebookShare();
} else if (which == 1) {
StartTwitterShare();
}
dialog.dismiss();
}
}).show();

private void StartFacebookShare() {
Intent intent = new Intent("android.intent.category.SEND");
intent.putExtra(Intent.EXTRA_SUBJECT, "URL");
intent.putExtra(Intent.EXTRA_TEXT, "http://www.stackoverflow.com");
intent.setClassName("com.facebook.katana", "com.facebook.katana.ShareLinkActivity");
startActivityForResult(intent, 0);
}
private void StartTwitterShare() {
String message = "www.stackoverflow.com"; //the string you want to tweet
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.twitter.android", "com.twitter.android.PostActivity");
intent.putExtra(Intent.EXTRA_TEXT, message);
startActivityForResult(intent, 1);
} catch (Exception e) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://twitter.com/intent/tweet?text=" + message));
startActivityForResult(intent, 1);
}
}


Some useful info can be found here and here, maybe search here or comment if you have suggestions for my code (I always like feedback ^^) or if you're stuck on something :)



.

stackoverflow.comm

[android help] Set semi-transparent drawable on top of TextView at runtime


In an application to manage the costs of a living community, an user can 'terminate' a month, which is then stored in a database.


In a specific Activity of this app, there are shown the last four months including their attribute 'terminated'. I want to show this to the user by putting a semi-transparent hook on top of the TextView containing this month. Consider this image as example:


enter image description here


It seems that this doesn't work properly in Android.



textView.setCompoundDrawablesWithIntrinsicBounds(...)


does put the image on top, and it's semi-transparent too, but the initial text of the TextView disappears. Additionally, since now I haven't discovered yet how to scale the image into that TextView.


This is the actual output:


enter image description here


Can anybody help me with that? Should I define the scaling parameters directly in the XML layout file?



.

stackoverflow.comm

[android help] Intent with shareing data from facebook and tweeter

android - Intent with shareing data from facebook and tweeter - 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 have a question. If exists in android any menu when I click on button I want to see icons from facebook and tweeter to share some data. Something like solution from this code:



String message = "Text I wan't to share.";
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, message);

startActivity(Intent.createChooser(share, "Title of the dialog the system will open"));


but only with icons from facebook and tweeter.
















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default






.

stackoverflow.comm

[General] Bluetooth controller android UI navigation possible?


If I stick my phone to my TV via HDMI while pairing the phone with a bluetooth controller/gamepad, can I use the gamepad to move around the android UI on my couch? Like surf the internet and open apps and such.



.

forum.xda-developers.com

[android help] Android: Can I use single InputStream for multi method?


I have some problem about using readline(). I have single inputStream it's from main class



private String url = "BoardLayoutSet/01_basic.templete";
private InputStream boardName = getResources().getAssets().open(url);
Board b = new Board(boardName);


And I send this "boardName" is InputStream to "Board" class. In this Board.class has constructor like this code below



public Board(InputStream boardName) throws IOException{
int[] d = LayoutDimensions(boardName); //<----First,use InputStream
....
......
build(null, boardName); //<<--Second,Use InputStream
}


First method is called by this constructor(Above). First method it use "InputStream" like this(Below)



public int[] LayoutDimensions(InputStream boardName) throws IOException {
BufferedReader reader1 = new BufferedReader(new InputStreamReader(boardName));
L1 = reader1.readLine(); // #Basic
L1 = reader1.readLine(); // %Level 1
L1 = reader1.readLine(); // space line
L1 = reader1.readLine(); // First row of board
for (int i = 0; i < L1.length(); i++) {
if (L1.charAt(i) != ' ') {
x++;
}
}
System.out.println(L1);
System.out.println("Width(x):" + x);
// ////////////////
boardName.reset();
BufferedReader reader2 = new BufferedReader(new InputStreamReader(boardName));
L2 = reader2.readLine(); // #Basic
L2 = reader2.readLine(); // %Level 1
L2 = reader2.readLine(); // space line
L2 = reader2.readLine(); // First row of board

while (L2.length()!=0) {
System.out.println(L2.charAt(0));
y++;
L2 = reader2.readLine();
}
System.out.println("Height(y):" + y);
.....
......

reader1.close();
reader2.close();
reader3.close();

return dimensions;

}


When I use one method only .it can work. Next, I need to call Second method like this



protected void build(Random r1, InputStream boardName) throws IOException {



if (r1==null) {
long seed = new Random().nextLong();
r = new Random(seed);
} else {
r = r1;
}


tTile = new Tile[depth][height][width];
int x;
int y;
int z=-1;

BufferedReader buffer = new BufferedReader(new InputStreamReader(boardName));

String L=null;
buffer.reset();
L = buffer.readLine(); //Basic
.......
......
......


it's error since this line>> L=buffer.readLine(); I tried to swap order : use second method before fist method . the second can use but first method is error. I think it's problem about Inputstream so I tried to make two Inputstream but it's not better.



.

stackoverflow.comm

[android help] Python and opencv program for android?

Python and opencv program for android? - 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 currently working on a contour image comparison proram in python & opencv. the program simply compares the real-time contour image from the webcam, and compares it to one of the various contour photos in my program. I would love to port this to android the easiest way possible, so i must ask, what is the best way to port a simplistic program like this? Also in theory i woud like to be able to distribute it via google play store and such. Any help would be much appreciated, as in resources/walkthroughs or just possibilities. My email is nwc6624 gmail.com if it is easier to simply email me. Thanks!


























You have to know how to extend python to java In other words google is your friend. I have extend python to c with pyOBJ-C meaning That the python code was formatted for use in C, thus you may be able to do so in Java.




















default






.

stackoverflow.comm

[android help] building ListView with Adapter


There is a main activity named CategoryListActivity in my project. Please see the following code:



public class CategoryListActivity extends Activity implements LoaderCallbacks> {
private ArrayAdapter mListAdapter;
private ListView listview;
private Categories categories = new Categories();
private static final int LOADER_ID_CHECKS = 1;

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

listview = (ListView) findViewById(R.id.listview);
mListAdapter = new ArrayAdapter(this,
android.R.layout.simple_list_item_1,
categories.categoryArray);
listview.setOnItemClickListener(mOnItemClickListener);
listview.setAdapter(mListAdapter);

getLoaderManager().initLoader(LOADER_ID_CHECKS, null, this);
}
...
}

public class Categories {
public List categoryArray;
}
public class Category {
public int categoryId;
public String categoryName;
public List questions;
}
public class Questions {
public String question;
public String answer;
}


I've tried to debug the project and it always stop at listview.setAdapter(mListAdapter). It says source not found When running the project, it gives me the following error:



04-25 20:45:01.106: D/AndroidRuntime(19891): Shutting down VM


04-25 20:45:01.106: W/dalvikvm(19891): threadid=1: thread exiting with uncaught exception (group=0x41760930)


04-25 20:45:01.106: E/AndroidRuntime(19891): FATAL EXCEPTION: main


04-25 20:45:01.106: E/AndroidRuntime(19891): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.flashcard/com.example.flashcard.CategoryListActivity}: java.lang.NullPointerException


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.app.ActivityThread.access$600(ActivityThread.java:141)


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.os.Handler.dispatchMessage(Handler.java:99)


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.os.Looper.loop(Looper.java:137)


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.app.ActivityThread.main(ActivityThread.java:5041)


04-25 20:45:01.106: E/AndroidRuntime(19891): at java.lang.reflect.Method.invokeNative(Native Method)


04-25 20:45:01.106: E/AndroidRuntime(19891): at java.lang.reflect.Method.invoke(Method.java:511)


04-25 20:45:01.106: E/AndroidRuntime(19891): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)


04-25 20:45:01.106: E/AndroidRuntime(19891): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)


04-25 20:45:01.106: E/AndroidRuntime(19891): at dalvik.system.NativeStart.main(Native Method)


04-25 20:45:01.106: E/AndroidRuntime(19891): Caused by: java.lang.NullPointerException


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.widget.ArrayAdapter.getCount(ArrayAdapter.java:330)


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.widget.ListView.setAdapter(ListView.java:462)


04-25 20:45:01.106: E/AndroidRuntime(19891): at com.example.flashcard.CategoryListActivity.onCreate(CategoryListActivity.java:58)


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.app.Activity.performCreate(Activity.java:5104)


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)


04-25 20:45:01.106: E/AndroidRuntime(19891): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)


04-25 20:45:01.106: E/AndroidRuntime(19891): ... 11 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...