|
Please don't repost if it doesn't go through immediately: the automated system flagged both of these as "possible spam" and it required human intervention to check. I then had to chase down the posts and delete the spare.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
how can we measure a room using frustum in AR.Or by using any other methods
|
|
|
|
|
|
Hey guys ,
I am currently having a bit of an issue with my app i'm building. It starts up fine but everytime I have it go to the keywordsearch activity it crashes. I looked at logcat and it seems to be an issue with the listview.setadapter on row 49 but I cant figure out why? I have looked on here for an answer but I just can't make it work. If you guys could help me that would be awesome.
**errors**
07-15 15:47:19.273 2204-4369/com.google.android.gms E/Herrevad: [309] RemoteReportsRefreshChimeraService.a: want to send authenticated request, but no Google account on device
07-15 15:47:19.310 1180-1618/? E/Drm: Failed to find drm plugin
07-15 15:47:19.387 2204-2769/com.google.android.gms E/Volley: [150] BasicNetwork.performRequest: Unexpected response code 307 for https:
07-15 15:50:44.074 4411-4411/? E/libprocessgroup: failed to make and chown /acct/uid_10058: Read-only file system
07-15 15:50:46.582 4411-4411/com.android.dreamworker.droomapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.dreamworker.droomapp, PID: 4411
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.dreamworker.droomapp/com.android.dreamworker.droomapp.Keywordsearch}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
at com.android.dreamworker.droomapp.Keywordsearch.onCreate(Keywordsearch.java:49)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
07-15 15:50:48.783 1536-1589/system_process E/InputDispatcher: channel '3e3c931 com.android.dreamworker.droomapp/com.android.dreamworker.droomapp.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
Keywordsearch.java file
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.SearchView;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;
import java.util.ArrayList;
public class Keywordsearch extends AppCompatActivity {
ListView keywordlist;
KeywordlistAdapter adapter;
String[] title;
String[] description;
int[] icon;
ArrayList<Model> arrayList = new ArrayList<Model>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle("Items List");
}
title = new String[]{"Battery", "Cpu", "Display", "Memory", "Sensor"};
description = new String[]{"Battery detail...", "Cpu detail...", "Display detail...", "Memory detail...", "Sensor detail..."};
keywordlist = findViewById(R.id.keywordlist);
for (int i =0; i<title.length; i++){
Model model = new Model(title[i], description[i]);
arrayList.add(model);
}
adapter = new KeywordlistAdapter(this, arrayList);
keywordlist.setAdapter(adapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView)myActionMenuItem.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
return false;
}
@Override
public boolean onQueryTextChange(String s) {
if (TextUtils.isEmpty(s)){
adapter.filter("");
keywordlist.clearTextFilter();
}
else {
adapter.filter(s);
}
return true;
}
});
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id==R.id.action_settings){
return true;
}
return super.onOptionsItemSelected(item);
}
}
**activity_keywordsearch.xml**
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Keywordsearch"
android:background="@drawable/achtergrond">
<ListView
android:id="@+id/keywordlist"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</RelativeLayout>
**KeywordlistAdapter.java**
import android.widget.BaseAdapter;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.android.dreamworker.droomapp.com.android.dreamworker.droomapp.keywordactivity.NewActivity;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class KeywordlistAdapter extends BaseAdapter {
Context mContext;
LayoutInflater inflater;
List<Model> modellist;
ArrayList<Model> arrayList;
public KeywordlistAdapter(Context context, List<Model> modellist) {
mContext = context;
this.modellist = modellist;
inflater = LayoutInflater.from(mContext);
this.arrayList = new ArrayList<Model>();
this.arrayList.addAll(modellist);
}
public class ViewHolder{
TextView mTitleTv, mDescTv;
}
@Override
public int getCount() {
return modellist.size();
}
@Override
public Object getItem(int i) {
return modellist.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(final int postition, View view, ViewGroup parent) {
ViewHolder holder;
if (view==null){
holder = new ViewHolder();
view = inflater.inflate(R.layout.row, parent, false);
holder.mTitleTv = view.findViewById(R.id.mainTitle);
holder.mDescTv = view.findViewById(R.id.mainDesc);
view.setTag(holder);
}
else {
holder = (ViewHolder)view.getTag();
}
holder.mTitleTv.setText(modellist.get(postition).getTitle());
holder.mDescTv.setText(modellist.get(postition).getDesc());
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (modellist.get(postition).getTitle().equals("Battery")){
Intent intent = new Intent(mContext, NewActivity.class);
mContext.startActivity(intent);
}
if (modellist.get(postition).getTitle().equals("Cpu")){
Intent intent = new Intent(mContext, NewActivity.class);
mContext.startActivity(intent);
}
if (modellist.get(postition).getTitle().equals("Display")){
Intent intent = new Intent(mContext, NewActivity.class);
mContext.startActivity(intent);
}
if (modellist.get(postition).getTitle().equals("Memory")){
Intent intent = new Intent(mContext, NewActivity.class);
mContext.startActivity(intent);
}
if (modellist.get(postition).getTitle().equals("Sensor")){
Intent intent = new Intent(mContext, NewActivity.class);
mContext.startActivity(intent);
}
}
});
return view;
}
public void filter(String charText){
charText = charText.toLowerCase(Locale.getDefault());
modellist.clear();
if (charText.length()==0){
modellist.addAll(arrayList);
}
else {
for (Model model : arrayList){
if (model.getTitle().toLowerCase(Locale.getDefault())
.contains(charText)){
modellist.add(model);
}
}
}
notifyDataSetChanged();
}
}
**You may not need these but if you do here they are**
**Model.java**
public class Model {
String title;
String desc;
public Model(String title, String desc) {
this.title = title;
this.desc = desc;
}
public String getTitle() {
return this.title;
}
public String getDesc() {
return this.desc;
}
}
**row.xml**
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp">
<TextView
android:id="@+id/mainTitle"
android:text="Title"
android:textStyle="bold"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/mainDesc"
android:text="Description"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
Again, if any of you could help me that would be **Awesome!**
Thank you!
|
|
|
|
|
The exception guides you straight to the location where this error is coming from:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
As per your code, there can be two ways to fix this,
keywordlist = findViewById(R.id.keywordlist);
Either, check that this keywordlist view has been inflated in the activity. Otherwise, if you are deep down in the hierarchy, try accessing this view from the view that your control is currently inside — happens with inflated views and layouts.
There are several other things that can go wrong, so best hands are still yours to find the bug, try debugging and seeing why is that object null.
java - Custom View children are null after inflating the view in Android - Stack Overflow
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Thank you for your response! I was wondering if you could elaborate on this?
Afzaal Ahmad Zeeshan wrote: try accessing this view from the view that your control is currently inside — happens with inflated views and layouts.
what do you mean by the view that my control is inside and how would that work?
Thank you for looking into it. I really appreciate it.
|
|
|
|
|
I shared a link for a thread that talks about a common problem in Android programming. The function findViewById() tries to capture the View from the current context or the scope, which is mostly the Activity . When you try to find the view by the ID of, keywordlist , runtime will try to find the view inside the current context, most likely, Activity you are currently inside.
For example, you just inflated the activity_main layout, but you are having the ListView defined inside another layout file,
<ListView
android:id="@+id/keywordlist"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
This is one of the problems that you might be facing, because your View is not even inflated — unless your activity_main tries to inflate this view internally, which I am not sure of as you did not show the code for that activity.
I did not run the code, or analyze it completely, but most likely there are two things that might go wrong here,
- The view does not get inflated, or it not found in the context you are trying to look under.
- You are not using the correct ID of the element.
Also check if the ID is being used correctly and for the view you are expecting to be there. Debug, debug, debug. Also try to listen on a click listener of the view and find the ID or parents of that to check the hierarchy of the elements.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Thank you,
I will try these options and see if that fixes it.
Thank you for the help.
|
|
|
|
|
I just fixed it! Thank you for your help otherwise I would have been stuck here for a month.
|
|
|
|
|
Hello to all,
I'm looking for somebody to write app with in AS. All data/project is ready just programming left to be done. Since I'm only 'a year experienced' beginner, I wish to work with somebody more advanced in java-android programming. There is a big chance of success so we can work as co-creators in coming projects too.
|
|
|
|
|
Sorry, but these forums are for technical questions, not recruitment. Try freelancers.com.
|
|
|
|
|
|
Can you please explain what type of project it is? Actually I have experience in building projects for some particular domains. Please let me know about the industry and other details that you can share.
|
|
|
|
|
Hi,
I have a lot of database text files arranged inside folders and subfolders. I want to restrict the files from accessing externally from the app. So asset/ raw folder is the best option and each file size is less than 50kb. And in asset folder the arrangement is similar to file system and in raw folder its based on id's. So i opt for asset folder.
The selection of the database file is done by the user. So a search dialog window for browsing the file would be the better option. But i don't find any sample code for accessing a asset file system using dialog window. Is it possible?.
Thanks
Nikhil.
|
|
|
|
|
NiKHiLMS wrote: But i don't find any sample code for accessing a asset file... Have you tried something like this?
"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
|
|
|
|
|
Thanks for the reply.
Actually I need a sample code for accessing a file in asset folder with the help of file browsing dialog window not this.
Anyway i dropped the plan, instead of file browsing dialog window, listview will be a better option. Files and folders inside the asset folder can be displayed in ListView and user can select what they need.
|
|
|
|
|
NiKHiLMS wrote: ...instead of file browsing dialog window, listview will be a better option. Those two things are mutually exclusive. Whether you have a dialog or not, you still need a container (e.g., ListView ) for the filenames.
"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 all. From out of 10 dialogs, I need one of the dialogs to start with landscape orientation. No other activity, fragment and dialog will be started with landscape orientation except this one dialog.
I have absolutely no idea how do I make this happen? Do I create some custom control ?
Thanks for any input.
|
|
|
|
|
I have an Android application where customers can purchase and put orders
Every customer can put order and I just have one `JSON` file in the `PHP` server to collect the orders from different customers
The problem is if one customer puts his/her order, the `JSON` file shall be locked in order to prevent collision and if it is locked, how can another customer put order at the exact same time?
To solve this issue, and for test, I decided to have a folder in the server where every customer (who is going to put an order) can put his unique ID there (uploading a text file with the name of the customer's ID) and I just read that folder to see who has put any order and then I delete the file which was uploaded by the customer indicating he/she has just put an order to be ready from another order from that customer
(every customer creates a folder with his/her unique ID name to put detailed list of his/her orders and this is handled by PHP code)
It works fine but does not seem to be a true manner from performance point of view
Any suggestion?
|
|
|
|
|
The PHP server should be able to handle multiple orders, just like any other web server.
|
|
|
|
|
The point is writing to the same file at the same time and as I searched it may create corruption
|
|
|
|
|
Exactly why I made my comment. You should not try to write to a single file in a multi-user application; it makes no sense.
|
|
|
|
|
AndroidVH wrote: one `JSON` file in the `PHP` server to collect the orders from different customers Unlike an ASP or PHP page, a JSON file does not "collect" anything. Based on what you've provided, unless you are doing something totally wrong, there should be no way for it to become locked. If multiple clients request the same JSON file, the web server will deliver the file to each client without issue.
AndroidVH wrote:
Any suggestion? The whole "upload a file containing a customer number and/or order" approach seems way wrong to me.
When you make contact with a web server, a one-on-one relationship has been established. When you interact with a web page (e.g., PHP file), you are doing so with your "copy" of it. If some other client is also interacting with that same page, again it's on their own "copy" of it. The web server keeps track of all those connections (up to some upper limit).
Admittedly, I may be completely wrong on this. It borders on ecommerce which I have zero experience with. But what you are doing just seems kludgy and prone to error.
"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
|
|
|
|
|
Sorry, I meant the orders are stored in the JSON by PHP code
I changed the process so as to prevent writing to the same file by different clients
|
|
|
|
|
I have to record a live audio/vedio and convert it into udp packets and broadcast it over wifi but not working after recording.
This is my code
public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
random = new Random();
startAudioButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(checkPermission()) {
audioSavePathInDevice = Environment.getExternalStorageDirectory().getAbsoluteFile() + "/" + createRandomFile(5) + "Recording.3gp";
mediaRecorderReady();
try {
mediaRecorder.prepare();
mediaRecorder.start();
startListener();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
startAudioButton.setEnabled(false);
stopAudioButton.setEnabled(true);
Toast.makeText(getApplicationContext(), "Recording Started ", Toast.LENGTH_SHORT).show();
}else{
requestPermission();
}
}
});
stopAudioButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(),"Recording Completed",Toast.LENGTH_SHORT).show();
mediaRecorder.stop();
stopAudioButton.setEnabled(false);
buttonPlayLastRecordAudio.setEnabled(true);
stopAudioButton.setEnabled(true);
buttonStopPlayingRecording.setEnabled(false);
Toast.makeText(getApplicationContext(),"Recording Completed",Toast.LENGTH_SHORT).show();
}
});
buttonPlayLastRecordAudio.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) throws IllegalArgumentException,
SecurityException, IllegalStateException {
try{
startAudioButton.setEnabled(false);
stopAudioButton.setEnabled(false);
buttonStopPlayingRecording.setEnabled(true);
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(audioSavePathInDevice);
mediaPlayer.prepare();
mediaPlayer.start();
Toast.makeText(getApplicationContext(),"Recording Playing",Toast.LENGTH_SHORT).show();
}catch (IOException e){
e.printStackTrace();
}
}
});
buttonStopPlayingRecording.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
stopAudioButton.setEnabled(false);
stopAudioButton.setEnabled(true);
buttonStopPlayingRecording.setEnabled(false);
buttonPlayLastRecordAudio.setEnabled(true);
if(mediaPlayer != null){
mediaPlayer.stop();
mediaPlayer.release();
mediaRecorderReady();
}
}
});
}
private void init() {
startAudioButton = ( Button)findViewById(R.id.button);
stopAudioButton = ( Button)findViewById(R.id.button2);
buttonPlayLastRecordAudio = (Button) findViewById(R.id.button3);
buttonStopPlayingRecording = (Button) findViewById(R.id.button4);
stopAudioButton.setEnabled(false);
buttonPlayLastRecordAudio.setEnabled(false);
buttonStopPlayingRecording.setEnabled(false);
}
private void mediaRecorderReady() {
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
mediaRecorder.setOutputFile(audioSavePathInDevice);
}
private String createRandomFile(int i) {
StringBuilder stringBuilder = new StringBuilder( i );
int j =0;
while (j<i){
stringbuilder.append(randomaudiofilename.charat(random.nextint(randomaudiofilename.length())));
="" j++;
="" }
="" return="" stringbuilder.tostring();
="" }
="" private="" void="" startlistener()="" {
="" create="" listener="" thread
="" listen="true;
" thread="" listenthread="new" thread(new="" runnable()="" {
="" <a="" href="https://www.codeproject.com/Members/override">@Override
public void run() {
try {
Log.i(LOG_TAG, "Listener started!");
DatagramSocket socket = new DatagramSocket(BROADCAST_PORT);
byte[] buffer = new byte[BUF_SIZE];
DatagramPacket packet = new DatagramPacket(buffer, BUF_SIZE);
while(LISTEN) {
try {
socket.send(packet);
Log.i(LOG_TAG, "Listening for packets");
socket.receive(packet);
String data = new String(buffer, 0, packet.getLength());
Log.i(LOG_TAG, "Packet received from "+ packet.getAddress() +" with contents: " + data);
// String action = data.substring(0, 4);
}
catch(SocketTimeoutException e) {
if(!IN_CALL) {
Log.i(LOG_TAG, "No reply from contact. Ending call");
endCall();
return;
}
}
catch(IOException e) {
}
}
Log.i(LOG_TAG, "Listener ending");
socket.disconnect();
socket.close();
return;
}
catch(SocketException e) {
Log.e(LOG_TAG, "SocketException in Listener");
endCall();
}
}
});
listenThread.start();
}
private void stopListener() {
// Ends the listener thread
LISTEN = false;
}
private void endCall() {
// Ends the chat sessions
stopListener();
if(IN_CALL) {
call.endCall();
}
finish();
}
}
When i am using only MediaRecorder for recording it working but when i try for udp packet conversion it not ,basically not getting how to club recording and udp packet code.
modified 22-Jun-18 5:26am.
|
|
|
|
|