[android-developers] Digest for android-developers@googlegroups.com - 4 updates in 2 topics

NewToAndroid <rahulrasal@gmail.com>: Mar 23 09:03AM -0700

Hi all,
 
I am developing a live audio streaming app on Android Studio 1.0.1 and testing it on Samsung Galaxy s3 phone (not on emulator).
 
First I was getting IOException when i was doing setDataSource on media player object when using http:// url. I have set the INTERNET permission in manifest, still the issue was there (with different implementations of setDataSource).
 
Then I found out that, I need to have Access_network_state set in manifest. The moment I set that in manifest, I started getting error "neither the user nor current process has access network state permission".
I have tried writting access_network_state twice in the manifest (as suggested by few google search) and also, I have tried doing clean and build of the project.
Still getting the error "neither user nor process has access_network_state " error.
 
Is this a permission setup issue ??
when I am deploying the app from my laptop to the phone over a usb cable, is it not setting up the network access permissions ?
After an app is installed on my phone, how can I check, what permissions does the app have ??
 
I am thinking that, either on android studio or in my phone, I might have to do some settings so that, the permissions are actually given to the app while/after deployment.
 
Please help. I am on the verge of giving up ....
 
Thanks in advance.
NewToAndroid <rahulrasal@gmail.com>: Mar 23 04:03PM -0700

Hi All,
 
Its me again. I am adding to my original post here.
Looks like it is permissioning problem.
 
I have added following lines in the manifest file,
 
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE" />
 
Till now, I let Android development studio install the app directly on to
the phone, connected by USB cable. This time I copied the apk file from my
laptop(manually) to one folder on my phone (Galaxy S3). Then, I clicked on
the apk file ad installed it.
Before installing, the app installer asked "this app does not require any
special permissions, do you want to install ?". Why is this ??
As I have added the entries in the manifest file, I was expecting that,
before installing, Android will ask me about these 2 permissions.
 
Is there any problem with the build ? Do I need to change any setting in
studio so that, the apk file will pick up the permission information ??
 
Please help.
 
On Monday, March 23, 2015 at 4:03:38 PM UTC, NewToAndroid wrote:
Dan Cha <cubangt2@gmail.com>: Mar 23 02:50PM -0700

So i got past some of the earlier issues and changed my pages around to
work with actual data being returned from the webservice.
 
Everything is returned, populated and as i step thru the code, everything i
expect is there.. except when it gets to this line:
list.setAdapter(adapter);
 
 
From what i can tell it has something to due with the view within its own
thread??
If that is true, what can i look for to correct?
 
Here is my custom adapter code:
 
public class CustomListView extends ArrayAdapter<InventoryItem>
{
Activity context;
int layoutResourceId;
InventoryItem items[] = null;
 
public CustomListView(Activity context,int
layoutResourceId,InventoryItem[] items)
{
super(context, layoutResourceId, items);
this.context = context;
this.layoutResourceId = layoutResourceId;
this.items = items;
}
 
@Override
public View getView(int position, View view, ViewGroup parent)
{
View row = view;
ItemsHolder holder = null;
 
if(row == null)
{
LayoutInflater inflater = context.getLayoutInflater();
row = inflater.inflate(R.layout.activity_view_listview_single,
null, true);
 
holder = new ItemsHolder();
holder.imgItem =
((ImageView)row.findViewById(R.id.tvImageValue));
holder.txtCategory =
(TextView)row.findViewById(R.id.tvCategoryValue);
holder.txtDescription =
(TextView)row.findViewById(R.id.tvDescriptionValue);
holder.txtOwner = (TextView)row.findViewById(R.id.tvOwnerValue);
holder.txtQty =
(TextView)row.findViewById(R.id.tvQuantityValue);
}
else
{
holder = (ItemsHolder)row.getTag();
}
 
InventoryItem item = items[position];
return row;
}
 
static class ItemsHolder
{
ImageView imgItem;
TextView txtCategory;
TextView txtDescription;
TextView txtOwner;
TextView txtQty;
}
}
=================================
Here is my asynctask code:
 
private class ItemTask extends AsyncTask<Void,Void,Void>
{
private final ProgressDialog dialog = new
ProgressDialog(ViewInventoryActivity.this);
protected void onPreExecute(){
this.dialog.setMessage("Returning Item List...");
this.dialog.show();
}
protected Void doInBackground(final Void... unused)
{
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.build());

SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,METHOD_NAME);
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.dotNet = true;
envelope.setOutputSoapObject(request);

HttpTransportSE httpTransport = new HttpTransportSE(URL);


try
{
List<HeaderProperty> invHeaders = new LinkedList<HeaderProperty>();
httpTransport.call(SOAP_ACTION, envelope,
(List<HeaderProperty>)invHeaders);
SoapObject response = (SoapObject)envelope.bodyIn;

if(response != null)
{
SoapObject dataset = (SoapObject) response.getProperty(0);

SoapObject table = (SoapObject) dataset.getProperty("diffgram");
SoapObject dar = (SoapObject) table.getProperty("NewDataSet");
Integer recCount = dar.getPropertyCount();
items = new InventoryItem[recCount];
for (int i=0;i<recCount;i++)
{
SoapObject suvas = (SoapObject) dar.getProperty(i);
if (suvas != null)
{
String c;
String d;
String o;
String img;
String q;
c = suvas.getPropertySafelyAsString("Category").toString();
d = suvas.getPropertySafelyAsString("Description").toString();
o = suvas.getPropertySafelyAsString("Owned_x0020_By").toString();
img = suvas.getPropertySafelyAsString("Picture").toString();
q = suvas.getPropertySafelyAsString("Qty","null").toString();

items[i] = new InventoryItem(c, d, o, img, q);
}
}
}
}
catch (Exception exception)
{
textViewStatus.setText(exception.toString());
}
 
CustomListView adapter = null;
adapter = new
CustomListView(ViewInventoryActivity.this,R.layout.activity_view_listview_single,items);
list = (ListView)findViewById(R.id.list);
list.setAdapter(adapter);
return null;
}
 
protected void onPostExecute(Void result){
if(this.dialog.isShowing()){
this.dialog.dismiss();
}
}
}
 
=====================================
And here is my OnCreate code:
 
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_listview_display);
find_and_modify_text_view();
new ItemTask().execute();
}
 
=====================================
And here is the error i was finally able to see:
 
03-23 16:43:24.416 13243-13243/com.InventoryList.inventory E/dalvikvm﹕
>>>>> com.InventoryList.inventory [ userId:0 | appId:10248 ]
03-23 16:43:24.416 13243-13243/com.InventoryList.inventory E/SELinux﹕
[DEBUG] get_category: variable seinfocat: default sensitivity: NULL,
cateogry: NULL
03-23 16:43:24.486 332-822/? E/audio_hw_primary﹕
adev_close_input_stream, set jack_in to null
03-23 16:43:29.366 974-1082/? E/ViewRootImpl﹕ sendUserActionEvent()
mView == null
03-23 16:43:29.526 13243-13243/com.InventoryList.inventory
E/MoreInfoHPW_View﹕ Parent view is not a TextView
03-23 16:43:45.946 974-1368/? E/Watchdog﹕ !@Sync 7963
03-23 16:43:46.136 13243-13243/com.InventoryList.inventory
E/MoreInfoHPW_View﹕ Parent view is not a TextView
03-23 16:44:00.026 3081-3081/? E/accuweather﹕ [KK AccuPhone]>>> UIM:1466
[0:0] bTM 4 44
03-23 16:44:04.496 13243-13263/com.InventoryList.inventory
E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.InventoryList.inventory, PID: 13243
java.lang.RuntimeException: An error occured while executing
doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at
java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at
java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException:
Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:7249)
at
android.view.ViewRootImpl.focusableViewAvailable(ViewRootImpl.java:3384)
at
android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:661)
at
android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:661)
at
android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:661)
at
android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:661)
at android.view.View.setFlags(View.java:9841)
at android.view.View.setFocusableInTouchMode(View.java:6486)
at android.widget.AdapterView.checkFocus(AdapterView.java:891)
at android.widget.ListView.setAdapter(ListView.java:493)
at
com.InventoryList.inventory.ViewInventoryActivity$ItemTask.doInBackground(ViewInventoryActivity.java:149)
at
com.InventoryList.inventory.ViewInventoryActivity$ItemTask.doInBackground(ViewInventoryActivity.java:81)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
03-23 16:44:04.856 974-13271/? E/android.os.Debug﹕ !@Dumpstate >
sdumpstate -k -t -z -d -o /data/log/dumpstate_app_error
03-23 16:44:05.036 13243-13243/com.InventoryList.inventory
E/WindowManager﹕ android.view.WindowLeaked: Activity
com.InventoryList.inventory.ViewInventoryActivity has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView{434ddb90 V.E.....
R......D 0,0-1415,384} that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:480)
at
android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:267)
at
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:301)
at
com.InventoryList.inventory.ViewInventoryActivity$ItemTask.onPreExecute(ViewInventoryActivity.java:87)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
at android.os.AsyncTask.execute(AsyncTask.java:535)
at
com.InventoryList.inventory.ViewInventoryActivity.onCreate(ViewInventoryActivity.java:46)
at android.app.Activity.performCreate(Activity.java:5600)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2504)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2599)
at
android.app.ActivityThread.access$900(ActivityThread.java:174)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5748)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
03-23 16:44:15.946 974-1368/? E/Watchdog﹕ !@Sync 7964
Dan Cha <cubangt2@gmail.com>: Mar 23 03:17PM -0700

So i moved these lines to onPostExecute and it loads my page with the
appropriate number of rows, but nothing is populated.
In the "items" there are the 26 rows that should be returned, and now the
page loads 26 rows but no data is seen on the page.
 
 
protected void onPostExecute(Void result)
{
CustomListView adapter = null;
adapter = new
CustomListView(ViewInventoryActivity.this,R.layout.activity_view_listview_single,items);
list = (ListView)findViewById(R.id.list);
list.setAdapter(adapter);
 
if(this.dialog.isShowing()){
this.dialog.dismiss();
}
}
 
 
On Monday, March 23, 2015 at 4:50:20 PM UTC-5, Dan Cha wrote:
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to android-developers+unsubscribe@googlegroups.com.

No comments:

Post a Comment