|
Kotlin is fancy however regardless of whether I got why and how conclusion and scala have been made, I didn't actually comprehend the motivation behind Kotlin. The Java language is at a generally excellent spot, the additional layer Kotlin gives doesn't appear to be relevant enough
It is fancy, it finishes a few things, yet the business guidelines are better on each end IMHO. I read a contention saying that it is extremely simple doing parallelism in Kotlin since java 8 is additionally very simple getting it done.
|
|
|
|
|
I'm going to attach my .jar file to an already running apk in emulator(BlueStack). I can attach .jar file to running java application on windows. But for running apk in emulator, it is not the same. Any help for me. thanks.
modified 10-Oct-19 12:50pm.
|
|
|
|
|
What do you mean by "attach my .jar file to an already running apk"? How do you plan to attach it?
|
|
|
|
|
Thanks for your reply. I have one apk, but no project of it. At running time of the apk in emulator, I want to hook some functions of apk to get some information, so I'm going to inject my .jar to it. Before I have injected my agent jar file to running java application, but in case of apk I have no idea. Please help me.
|
|
|
|
|
|
There are a lot of android emulators are available that help you run the apk files in the PC. some of them are like bluestacks ,andy,coplayer,AMyDuos.Besides that you can install andriod in vmware and install apps
|
|
|
|
|
Hello there. I am setting a click listener on a relative layout. It works fine. But today I got couple of crashes on this click listener from the user. I set this click listener in the onCreate() function of the activity. Here is what my code looks like
@Override
protected void onCreate(Bundle savedInstanceState) {
layoutHomeButton = findViewById(R.id.layoutHomeButton);
layoutHomeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
}
And following is the exception I get
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3021)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3156)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1864)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:205)
at android.app.ActivityThread.main (ActivityThread.java:6991)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:884)
Caused by: java.lang.NullPointerException:
at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.ui.activities.ActivityPlayVideo.onCreate (ActivityPlayVideo.java:210)
at android.app.Activity.performCreate (Activity.java:7159)
at android.app.Activity.performCreate (Activity.java:7150)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3001)
what am I doing wrong? Thanks
|
|
|
|
|
layoutHomeButton = findViewById(R.id.layoutHomeButton);
It may be that the above line failed, so layoutHomeButton is null and causes the exception. Use the debugger to see if that is the case.
|
|
|
|
|
It is never null when I debug. It always finds a resource.
|
|
|
|
|
Then something else must be the problem, but it is impossible to guess what. You need to look at ActivityPlayVideo.java:210 if it is available.
|
|
|
|
|
Then you should be able to add:
layoutHomeButton = findViewById(R.id.layoutHomeButton);
if (layoutHomeButton != null)
layoutHomeButton.setOnClickListener(new View.OnClickListener()...
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hello there. I have this BroadcastReciever which I register and unregister dynamically, in a BASE activity. The purpose, of this receiver, is very simple. I check if HOME button is pressed? The registration of the receiver is as follows:
ActivityBase
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHomeWatcher = new HomeWatcher(this);
mHomeWatcher.setOnHomePressedListener(new OnHomePressedListener() {
@Override
public void onHomePressed() {
}
@Override
public void onHomeLongPressed() {
}
});
mHomeWatcher.startWatch();
}
protected void stopHomeWatcher(){
if(mHomeWatcher != null) {
mHomeWatcher.stopWatch();
mHomeWatcher.setOnHomePressedListener(null);
mHomeWatcher = null;
}
}
HomeWatcher
public class HomeWatcher {
public HomeWatcher(Context context) {
mContext = context;
mFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
}
public void setOnHomePressedListener(OnHomePressedListener listener) {
mListener = listener;
mReceiver = new InnerReceiver();
}
public void startWatch() {
if (mReceiver != null) {
mContext.registerReceiver(mReceiver, mFilter);
}
}
public void stopWatch() {
if (mReceiver != null) {
if(mContext != null)
mContext.unregisterReceiver(mReceiver);
}
}
class InnerReceiver extends BroadcastReceiver {
final String SYSTEM_DIALOG_REASON_KEY = "reason";
final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";
final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
if (reason != null) {
if(reason.trim().toLowerCase().equals("homekey")) {
}
}
}
}
}
}
As you can see, I test for various NULLs. Why do I still get this weird IllegalArgumentException ?
java.lang.IllegalArgumentException:
at android.app.LoadedApk.forgetReceiverDispatcher (LoadedApk.java:1012)
at android.app.ContextImpl.unregisterReceiver (ContextImpl.java:1360)
at android.content.ContextWrapper.unregisterReceiver (ContextWrapper.java:608)
at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.utils.HomeWatcher.stopWatch (HomeWatcher.java:39)
at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.ui.activities.ActivityBase.stopHomeWatcher (ActivityBase.java:442)
at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.ui.activities.ActivityMain.access$301 (ActivityMain.java:77)
at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.ui.activities.ActivityMain$15.onClick (ActivityMain.java:911)
at android.view.View.performClick (View.java:5703)
at android.view.View$PerformClick.run (View.java:22811)
at android.os.Handler.handleCallback (Handler.java:836)
at android.os.Handler.dispatchMessage (Handler.java:103)
at android.os.Looper.loop (Looper.java:203)
at android.app.ActivityThread.main (ActivityThread.java:6297)
|
|
|
|
|
Does the exception say that the receiver is not registered?
At a guess, you're calling unregisterReceiver twice.
I don't "do" Android dev, but I suspect you'd want something more like this:
public void setOnHomePressedListener(OnHomePressedListener listener) {
mListener = listener;
}
public void startWatch() {
if (mListener != null && mReceiver == null) {
mReceiver = new InnerReceiver();
mContext.registerReceiver(mReceiver, mFilter);
}
}
public void stopWatch() {
if (mReceiver != null) {
mContext.unregisterReceiver(mReceiver);
mReceiver = null;
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hey forum, I'm designing an email for an email marketing campaign, and I want that when a person clicks on a button, open a page in WordPress and capture the email of the person who clicked on it to autofill a form with that email. is possible.?
in my case, it's for people to confirm that they want a free value and I would like them not to have to write their mail again.
Thanks
|
|
|
|
|
What does this have to do with Android? The Web Development forum[^] would have been the obvious place to ask this.
When you send the email, add the recipient's email address to the hyperlink as a querystring. You'll need to URL-encode it to make sure it transfers properly.
For example:
<a href="https://your-wordpress-site/some-page.ext?foo%40test.domain">Click me!</a>
When the user clicks on the link, you can then extract the value from the querystring using server-side code (or Javascript).
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This method allows you to manually connect to Gmail's SMTP servers to send your WordPress emails. First, you need to visit Settings » WP Mail SMTP page to configure the plugin settings. You need to start by providing the Gmail address you want to use in the From email field, and your name in the name field.
|
|
|
|
|
Good work, Keep designing.
|
|
|
|
|
I have set up a client-server architecture such that my raspberry pi 3 records audio, performs some analysis on it, and then sends the data (via TCP) to the android app to display on the app screen. The recording and analysis is done and I am able to make the connection and transfer string data that displays on the app with no problem. However, I have been unsuccessful in transferring an image from rpi to android app. So basically, the image is stored on the rpi and I an attempting to transfer the image to the app to display it. I have been working on this for over a week with no luck so any help would be greatly appreciated!
My current implementation (all code provided below):
On rpi (python): Like I said, sending strings and displaying them on the android app is done without any problem. When I am sending the image portion of the audio analysis, I send a string first that says "?start" so that the android side knows that an image instead of a string is about to be sent (and will wait to update the GUI until it receives the entire image). Then, I open the image stored on rpi and read the entire image as a byte array (typically about 40-50k bytes). I get the length of the byte array and send that as a string to android app. Finally, I send the byte array to the android and it waits for an OK message from the app. All of this works without reporting any errors.
On android app (java): When the app receives the "?start" string, it then uses a Buffered Reader (which is what I used to read the string data I had transferred to the app successfully earlier) to read the size of the image byte array. Then, I create 2 buffers, msg_buff and img_buff. msg_buff will read in 1024 bytes at a time while img_buff will hold the entire byte array of the image. In the infinite while loop, I have a DataInputStream, called in, read bytes into msg_buff and returns the number of bytes read. Then, I concatenate the copied contents of msg_buff into img_buff. Once the bytes read from in is -1 or the img_offset (which is just the total number of bytes read) is greater than or equal to the size of the image bytes array, the while loop is broken. Then, I would attempt to save the image to android internal storage and then load it later to an imageView to display it. This code does successfully read in the bytes until there are around 2000-3000 bytes left to be read and then it seems to freeze on the int bytes_read = in.read(msg_buff, 0, msg_buff.length) line. I have not been able to get past that point so I do not know if saving the image to internal storage and then loading it to imageview that way will work either.
I have also tried using base64 encoding/decoding but that also kept producing errors. I have tried rpi only sending 1024 bytes of the image at a time but that also did not work. I have tried several implementations of this approach but nothing has worked so far. If anyone sees anything wrong or has another approach, I am all ears!
Android Studio (app side):
InputStream sin = socket.getInputStream();
OutputStream sout = socket.getOutputStream();
DataInputStream in = new DataInputStream(sin);
mBufferIn = new BufferedReader(new InputStreamReader(socket.getInputStream()));
while (mRun) {
mServerMessage = mBufferIn.readLine();
if (mServerMessage != null && mMessageListener != null) {
if(mServerMessage.equals("?start"))
{
int size = Integer.parseInt(mBufferIn.readLine());
byte[] msg_buff = new byte[1024];
byte[] img_buff = new byte[size];
int img_offset = 0;
while(true){
int bytes_read = in.read(msg_buff, 0, msg_buff.length);
if(bytes_read == -1){ break; }
System.arraycopy(msg_buff, 0, img_buff, img_offset, bytes_read);
img_offset += bytes_read;
if( img_offset >= size) { break; }
}
ContextWrapper cw = new ContextWrapper(ApplicationContextProvider.getContext());
File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
File mypath = new File(directory, "signal.jpeg");
Bitmap bitmap = BitmapFactory.decodeByteArray(img_buff, 0, img_buff.length);
FileOutputStream fos = null;
try{
fos = new FileOutputStream(mypath);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
byte[] OK = new byte[] {0x4F, 0x4B};
sout.write(OK);
} catch (Exception e) {
e.printStackTrace();
}
Raspberry Pi (python):
def image_to_byte_array(image_file, conn):
with open(image_file, 'rb') as imageFile:
content = imageFile.read()
conn.sendall("?start\n".encode('utf-8'))
size = len(content)
strSize = str(size) + "\n"
conn.sendall(strSize.encode('utf-8'))
conn.sendall(content)
Note that conn is the connection between the app and the rpi and the images are PNG.
If anyone knows why this isn't working or has a better way for me to do this, I would greatly appreciate it!! Thank you in advance!! :)
|
|
|
|
|
Your problem description (which is very clear, thank you), and code all seems correct. The way you are handling the data between the two endpoints should do what you want. When the program freezes on the in.read , it usually means that the network layer is waiting for a packet to be received. You could try setting a timeout value so the read does not block forever. This will at least let you check how much data is still not received: Socket.setSoTimeout(int) (Java Platform SE 7 )[^]
|
|
|
|
|
i need complete code of a search engine where it crawl minimum of 5 sites and must also allow a user to enter a term and get its url
|
|
|
|
|
|
Google might help you—not kidding, they usually do release some guidance on how they work on the crawlers, indexers etc.
If that is not what you are looking for, then try to study Elasticsearch and see how it works; GitHub - elastic/elasticsearch: Open Source, Distributed, RESTful Search Engine. But remember, before reading the source code, it might need that you study the basics of how coding works as well as the core components of computer science, as search engines or indexation gets pretty messy down the road.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
hello, am looking for a simple code in C# to develop QR scanner for android phone camera. please help.
|
|
|
|
|
|
hi
i have android webview app. one of my parts is to download blob sound data link to my device.my step as flow:
1- live audio record
2- create blob url
3- i can listen the url, and once press download i receive this message (unknown blob protocol)
any solution please?
|
|
|
|