I am running on helloword application as getting started with android application developement. but i cant able to see output in android emulator. it will show only android in the emulator screen. and i am just print "Hello from Brijesh". but it will not display in the emulator of the android. actually i follow the instruction in the following link.
http://developer.android.com/guide/tutorials/hello-world.html
but not getting out put.
can any one help me out.
thankx.
If i understand correctly, you would like to output some debugging messages to the screen ?
In standard java you can use the System.out.println method, but with android i suggest you use the Dalvik debugger.
Use:
Log.i("mytag","My simple message");
And se the output by using the Dalvik Debug Monitor
Start the Dalvik Debug Monitor with:
c:\android-sdk\tools\ddms.bat
Just change the foldername to where you have installed the SDK.
Now the debugger application will start (next to the emulator), and your message will be shown with green text.
You can also view System.out.println commands in the Dalvik Debug Monitor or in LogCat by creating a filter for a Log Tag containing "System.out".
If you want to print "Hello from Brijesh" through XMl then use this code.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world"
/>
And if you want to print that using java then,
TextView tv = new TextView(this);
//Set a text into view
tv.setText("Hello World");
//set the view into activity view container
setContentView(tv);
Related
I am new to app development and have come across an issue my course hasn't yet covered but requires.
I have created a simple app that generates a log entry using Log.i after clicking a button - see screenshot below.
link to screenshot
As you may well see, no logs have been generated at all for the running emulator. This happened on an earlier app and after searching for an answer, found that going to the terminal and finding the appropriate directory, I could restart the adb using the 'kill-server' and 'start-server' commands. As this didn't work, I found the file in windows explorer and double clicked the adb.exe file. This seemed to fix the problem.
Having started another project (the one linked in the screenshot), the same problem has arisen but the same steps do not correct the issue and as such have nothing being generated in the logcat.
*beneath the emulator you see, I have nothing in the search box, the logcat is set to verbose and regex(?) is ticked.
Any help with this would be greatly appreciated as i'm reluctant to proceed with the course material before sorting out this issue.
Thanks.
some additional information I have found in the 'AVD' section of the 'Run' Window :
libpng warnings
adb successful start?
EDIT - requested code
EDIT 2 - It's a bit of a bodge but it seems the adb operator command 'logcat' used in the Terminal, turns the terminal into the logcat i.e. c:..\sdk\adb logcat' - all my missing logs, including the ones generated by the buttonClicked function appear in the terminal and new logs also appear there.
Terminal as logcat
Thank you for your responses but maybe someone knows a way to fix the logcat itself, i'd appreciate the answer. Thanks again.
I have managed to resolve the issue by closing all related software, rebooting my laptop and running the adb.exe file in the ..\android\sdk\platform-tools\ directory before launching the android studio.
Hope this helps if anyone else has the same issue.
Stitches S, I think you are not calling the buttonclicked method anywhere as I haven't seen it calling in the screenshot. But if you are calling it somewhere else then try log.d() to print that. It always works for me.
if you want to see log on button click set the buttonClick method inside the oncreate(), may be its doing nothing that's why not showing any log
this code is working in my case:
public class About_us extends AppCompatActivity {
TextView header, address;
private String Info="Info";
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contact);
header=findViewById(R.id.head);
address= findViewById(R.id.tv_address);
}
public void buttonClick(View view){
Log.d( Info,"button is clickd" );
}
}
and this is my xml view
<TextView android:id="#+id/head"
android:onClick="buttonClick"
android:layout_width="match_parent"
android:background="#color/third"
android:text="#string/app_name"
android:gravity="center"
android:textSize="20sp"
android:textColor="#color/first"
android:layout_height="30dp"/>
I developed a simple javafx application to be ported in Android Environment, however I cant type any characters in the TextField. I guess its a bug, how to fix this one?
Th problem on galaxy S5 android 5.0.1 is not present but on galaxy tab 4 android 5.0.2 it doesn't work i type but none is displyed.
Tried with normal textfield. And the problem persist also I have added the properties .
Another strange rhig is that the space where recognizer. And the del button . The text not
THe code by example is very easy
Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
double width = visualBounds.getWidth();
double height = visualBounds.getHeight();
TextField tt= new TextField();
tt.setTranslateY(-150);
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(tt);
borderpane.setCenter(stackPane);
Scene scene = new Scene(borderpane, width, height);
stage.setScene(scene);
Assuming that CustomTextField is just a custom TextField, this is a known issue, not related to the CustomTextField itself, given that it works in other device.
If you debug it:
./adb logcat -v threadtime
you surely find an exception that explains the issue: a StackOverFlow exception.
On older devices it can be solved adding this: create a java.custom.properties file, and include in it this property:
monocle.stackSize=128000
You may also include this one:
monocle.platform=Android
(it will be soon included by default in the next version)
Put the file at the root of your classpath, e.g. in the folder src/android/resources of your project.
Build and deploy the project on your mobile and check again.
I have created a blank activity project in Android Studio choosing API 14 (4.0 ICS) as the Minimum SDK.
In the main activity I assigned an id to the default 'hello world' TextView as below
<TextView
android:id="#+id/hw_1"
android:text="#string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
I then tried to change the default 'Hello world' message programmatically by doing
TextView tv = (TextView) findViewById(R.id.hw_1);
tv.setText("my new message");
However, I keep getting 'cannot resolve symbol TextView' and when trying to import I just do not see the TextView in the list of the widgets under android.widget package as depicted in the image below.
I am just starting Android and thinking that I might be missing something obvious but can't figure out what exactly cause I do see TextView inside the Android jar linked to the project etc.
Check the image below.
In case someone runs into this.
I figured there should be something on the IDE level and decided to check out how IntelliJ decides what to show in the import popup. After few minutes of digging I found the "Exclude from Import and Completion" section under IDE Settings -> Editor and there it was - the TextView import was explicitly excluded from import and completion suggestoins.
Not sure how it got there in the first place, but oh well ..
i want see the console output so i use the Logcat but the logcat is not display any output messages. i also restart eclipse.also click on devices log in android DDMS.i also do the Reset All perspective of DDMS.but i can`t success.
Select the device/emulator in DDMS when its in online mode.And there is '+' sign(green coloured) in left panel under "Saved Filters" of the LogCat.Click it and add your whole package name in "Filter Name" and "by Application Name".Try this.
Make sure that in your Logcat the buttons to the top right aren't selected. One of them blocks the Logcat to display new logs. Hope that helps.
How can I trace the output from eclipse and the android simulator. I am used to doing it in Flash and actionscript.
In AS3 it would be:
trace('my trace statement');
You have a few options. One is the java.util.logging.ConsoleHandler class: http://developer.android.com/reference/java/util/logging/ConsoleHandler.html
ConsoleHandler console = new ConsoleHandler();
console.publish(new LogRecord(Level.INFO, "Hello logging!"));
Another option is using the Log class:
http://developer.android.com/reference/android/util/Log.html
Log.v("MyIdentifier", "Hello logging!");
In android use the Log class to provide this. Simply pick a level you want "debug, warning, info" and then use the function. ie `Log.d("tag","message");
Then this message will appear in the LogCat Eclipse window