How to print the log in android chromium? - android

I am new at worknig on android chromium, and I need to print the log msg in it, then how to print the log in android chromium, which interface can be used to print log?

There several ways to print the log in android chromium, and you try the two flowing ways:
1. The first way:
//Add the head file
#include <cutils/log.h>
#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "Your Tags", __VA_ARGS__)
//use the XLOGC to print the log
XLOGC("Your log message");
2. The second way:
//Add the head file
#include "base/logging.h"
LOG(INFO) << "Your log message";

Related

How to send SMS with C++ Builder in Android

While searching the internet I came across the topic of sending SMS but unfortunately I did not find any example for C ++ Builder. Everything is written in Delphi. I tried to rewrite the instructions in C ++ and got this code:
#include <Androidapi.Helpers.hpp>
#include <Androidapi.JNI.JavaTypes.hpp>
#include <Androidapi.JNI.Telephony.hpp>
#include <Androidapi.JNI.GraphicsContentViewText.hpp>
#include <Androidapi.JNI.App.hpp>
#include <Androidapi.JNI.Net.hpp>
JString* wiadomosc = StringToJString( L"Wiadomość" );
Jnet_Uri* URI;
JString* destAdress;
URI = StrToJURI( "12345678" ); // phone number
_di_JIntent Intent = TJIntent::JavaClass->init( TJIntent::JavaClass->ACTION_VIEW, URI ); //ACTION_VIEW ACTION_SEND
Intent->setType( StringToJString("text/plain") );
//Intent->putExtra( TJIntent::JavaClass->EXTRA_TEXT, wiadomosc ); StringToJString('sms_body')
Intent->putExtra( StringToJString("sms_body"), wiadomosc );
::SharedActivityContext()->startActivity( Intent );
//SharedActivity()->startActivity(Intent);
The program works but not as I've expected. The application selection window appears, and despite permanent SMS set as default I can not send sms without typing a phone number and text message even though that data is present in the code. Please give me a hint how to send sms without using the default program on Android.

android log's time-stamp addition

while looking in android logging frame work -
I checked /dev/log/main |system |event log files. in these log file I dont see time stamp. but at the same time "logcat -v time" display time stamp along with log.
I check Logcat code Its reading androidlog_entry from /dev/log/* buffers and displaying on cmdline.
While tracing android logging code , I could not find at what point we are adding timestamp with our log.
I did trace following flow -
LOGI("pre_alloc_cap_mem_thread_init: inited=%d", obj->mPreAllocCapMemInited);
#define LOGE ALOGE
#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, VA_ARGS))
#define LOG_PRI(priority, tag, ...) \
android_printLog(priority, tag, VA_ARGS)
#define android_printLog(prio, tag, fmt...) \
__android_log_print(prio, tag, fmt)
int __android_log_print(int prio, const char *tag, const char *fmt, ...)
{
va_list ap;
char buf[LOG_BUF_SIZE];
va_start(ap, fmt);
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
va_end(ap);
return __android_log_write(prio, tag, buf);
}
and on and on till NR_writev system call .
can somebody please guide me, when Its adding timestamp to android logs.
I appreciate help.. what ever i could get ..
But i have figure out it -
"Android frame work does not add time stamp, threadid etc. to android logs that goes to /dev/log/, but It rather pass it down to kernel to logger driver(check logger.c in kernel code) that further add up the timestamp+PID etc. as prefix to each android log. "

In Zebra RW420 , line print mode not working in android

I am using zebra rw420 printer for printing a bill from my android mobile just like the image.
When I trying to print a label it is working fine.
but when I try to print in line-print mode it is giving a blank print.
Code I am using is
String cpclConfigLabel = "! U1 setvar {0} {1}, \"device.languages\", \"line_print\"\r\n"
+ "!U1 SETLP 5 2 46\r\n"
+ "AURORA'S FABRIC SHOP\r\n"
+ "!U1 SETLP 5 2 24\r\n" + "123 CASTLE DRIVE";
try {
configLabel = cpclConfigLabel.getBytes("US-ASCII");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
printerConnection.write(configLabel);
I am using Developer Demo from Zebra sdk,
Can anyone tell me what is wrong with my code?
The SDK was not designed for use with the printers in line mode. It will upon detecting that the printer is in line mode put it in ZPL mode.
The reason for this is that the SDK is set up to allow for status checking, template printing, and some other functions that will not work when the printer is in line mode.
Changing the printer back to line mode like you are trying to do will work for the printing portion, but if you try to use the status commands or some of the other SDK features you will start to get exceptions.
To print receipts and invoices which are variable length in ZPL you can do the following:
Set the printer media mode to continuous.
Create a template for the receipt header, line, and footer.
2a. Each of those templates will be a fixed height so set the "^LL" command for each template.
2b. Set the orientation of the template to inverted "^POI"
2b. Each of those templates have variables that can be filled in
Split your runtime data and recall the formats filling in the data.
You will essentially use templates instead of printing each line
Header
Line
Line
...
Line
Footer
Noticed a few syntax errors:
First line: remove '{0} {1}, ' and comma as well. It should read "! U1 setvar \"device.languages\" \"line_print\"\r\n".
Second and fourth line: insert a space between '!' and 'U1'.

Android NDK __android_log_print function and LogCat

I have a function like
__android_log_print(ANDROID_LOG_INFO, "HelloNDK!");
on my C code
I wouldn't find that output on my LogCat. What kind of filter I need to setup
by Log Tag, by Log Message, by Application Name, by Log Level...etc.
You don't find output because you have misused the function. The function has the prototype:
int __android_log_print(int prio, const char *tag, const char *fmt, ...);
So you must supply a "tag" as well as the format.
For example
__android_log_print(ANDROID_LOG_INFO, "MyTag", "The value is %d", some_variable);
Once you use the function properly, you can use any filtering method (or none at all - such as you'd get from the adb logcat command without further arguments) just as with java code.

Can I call `Log.*` within my C code? I want to debug using LogCat

I am stuck and am getting an error somewhere within my C code, and I do not know where. I would like to use the simple Log.i( tag, msg ) or Log.e( tag, msg ) commands. I have looked around online and have found two other questions on SO but neither of them deal with exactly what I'm saying.
This method is not what I'm looking for...
And this is exactly what I'm looking for, but in C++, not C
If the syntax in C++/C is the same, I'm sorry but I have little experience in both.
Syntax in C is the same
#include <android/log.h>
#define TAG "MYDEBUG"
#ifdef DEBUG
# define D(x...) __android_log_print(ANDROID_LOG_INFO, TAG , x)
#else
# define D(x...) do {} while (0)
#endif
# define W(x...) __android_log_print(ANDROID_LOG_WARN, TAG , x)
# define E(x...) __android_log_print(ANDROID_LOG_ERROR, TAG , x)
#include <cutils/log.h>
#define LOG_TAG "MYDEBUG"
...
ALOGD("Here we are!");
In older releases the macro was:
LOGD("Here we are!");

Categories

Resources