The issue is purely with the contents inside the tables. If the table is not empty (with one or more records), application works perfectly. I am deleting the contents of table and immediately after that reading the same table, it throws exception and app force closes. I tried searching for it but couldn't conclude. The key point is : index out of bound exception which is thrown at movetofirst() method of cursor when i am going to read the table, i suppose... Please help.
dimanche 3 mai 2015
display file data in an android app?
I am trying to do an android project. In that, I have created a file named fie.txt. I want the data(integers) stored in that file. How can I to retrieve and display that using android studio?
"class extends activity{}" throws "unfortunately app has stopped" while prefixing with "public" doesn't
I have a small app like this
package com.ibuk.app;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class HelloActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
That one works. But if I don't prefix the Activity class with public it throws the error Unfortunately app has stopped. Shouldn't a class be public by default? What's going on?
I have a set of latlong bounds and I want to know a hotels in those bounds. Are there any freely available APIs / databases to do so.
I have a set of latlong bounds and I want to know all available hotels in those bounds. Are there any freely available APIs / databases to do so.
I am trying to create android application to insert data in sql server through web servervuc
I am new in android here m trying to save some data in SQL server from android through a web service but empty row inserted in SQL server....
Here is Web service code... this is working fine
[WebService(Namespace = "http://threepin.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// [System.Web.Script.Services.ScriptService]
public class myWebService : System.Web.Services.WebService
{
[WebMethod]
public String insert(String name, String password)
{
SqlConnection conn = new SqlConnection("Data Source=.\\ ; Initial Catalog=user; Integrated Security=true");
SqlCommand insert = new SqlCommand("insert into login(name, password) values('" + name + "','" + password + "')", conn);
try
{
conn.Open();
insert.ExecuteNonQuery();
return name + password;
}
catch(Exception exp)
{
conn.Close();
return exp.Message ;
}
}
}
}
And this is android code file MyTask.java
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Handler;
import android.util.Log;
public class MyTask extends AsyncTask<String, Void, String>
{
public String SOAP_ACTION = "http://ift.tt/1AwfP1l";
public String OPERATION_NAME = "insert";
public String WSDL_TARGET_NAMESPACE = "http://threepin.org";
public String SOAP_ADDRESS;
private SoapObject request ;
private HttpTransportSE httptransport;
private SoapSerializationEnvelope envelope;
Object response = null;
Context context;
Handler mhandler;
ProgressDialog pd;
String Result;
boolean isValid;
public MyTask(Context context)
{
this.context = context;
pd = new ProgressDialog(context);
}
@Override
protected void onPreExecute()
{
super.onPreExecute();
pd.setMessage("Inserting Data");
pd.setIndeterminate(false);
pd.show();
Log.d("MyTag", "On pre Execute");
}
@Override
protected String doInBackground(String... params) {
Log.d("MyTag","do in background");
SOAP_ADDRESS = "http://"+params[0]+"/myWebService.asmx";
request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME);
Log.d("MyTag","do in background 1");
Log.d("MyTag", "do in background 2 "+request);
request.addProperty("name",params[1]);
Log.d("MyTag", "input name = "+params[1].toString());
request.addProperty("password",params[2]);
Log.d("MyTag", "input password = "+params[2].toString());
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
Log.d("MyTag", "do in background 3 "+request.toString());
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
try{
httptransport = new HttpTransportSE(SOAP_ADDRESS);
httptransport.call(SOAP_ACTION, envelope);
response = envelope.getResponse();
Log.d("MyTag", "response = "+response.toString());
}
catch(Exception exp)
{
response = exp.getMessage();
Log.d("MyTag", "exception : "+response.toString());
}
return null;
}
@Override
protected void onPostExecute(final String result) {
super.onPostExecute(result);
Log.d("MyTag", "in post execute");
pd.dismiss();
}
}
Unable to add items to listview in Fragment
I am trying to get a bundle and adding that value to the listview which crashes my app.
TaskActivity:
public class AddTask extends Activity {
Button addtask;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_task);
// get action bar
ActionBar actionBar = getActionBar();
// Enabling Up / Back navigation
actionBar.setDisplayHomeAsUpEnabled(true);
addtask = (Button) findViewById(R.id.btnaddlist);
findViewById(R.id.btnaddlist).setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View arg0) {
EditText edit = (EditText) findViewById(R.id.tskname);
Intent i = new Intent(AddTask.this,
MainActivity.class);
Bundle bundle = new Bundle();
String TaskName = edit.getText().toString();
// Add your data from getFactualResults method to bundle
bundle.putString("NewTask", TaskName);
i.putExtras(bundle);
startActivity(i);
}
});
}
}
This is how my HomeFragment looks:
public class HomeFragment extends Fragment {
ListView lv;
public HomeFragment(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_home, container, false);
Bundle extras = getActivity().getIntent().getExtras();
String ItemName = extras.getString("NewTask");
lv = (ListView)rootView.findViewById(R.id.tasklist);
if (extras != null) {
ArrayList<String> list = new ArrayList<String>();
ArrayAdapter<String> Listadapter;
Listadapter = new ArrayAdapter<String>(getActivity().getApplicationContext(),android.R.layout.simple_list_item_1, list);
list.add(ItemName);
lv.setAdapter(Listadapter);
}
return rootView;
}
}
Home Fragment xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/tasklist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
Logcat exception:
05-03 13:01:12.949: E/AndroidRuntime(30276): FATAL EXCEPTION: main
05-03 13:01:12.949: E/AndroidRuntime(30276): Process: com.sample.example, PID: 30276
05-03 13:01:12.949: E/AndroidRuntime(30276): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.widget.AbsListView.obtainView(AbsListView.java:2344)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.widget.ListView.measureHeightOfChildren(ListView.java:1270)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.widget.ListView.onMeasure(ListView.java:1182)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.View.measure(View.java:17448)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.widget.RelativeLayout.measureChild(RelativeLayout.java:697)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:481)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.View.measure(View.java:17448)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5465)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.View.measure(View.java:17448)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:762)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.View.measure(View.java:17448)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5465)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.View.measure(View.java:17448)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5465)
05-03 13:01:12.949: E/AndroidRuntime(30276): at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:447)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.View.measure(View.java:17448)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5465)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
05-03 13:01:12.949: E/AndroidRuntime(30276): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2560)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.View.measure(View.java:17448)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2031)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1189)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1402)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1077)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5884)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.Choreographer.doCallbacks(Choreographer.java:580)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.Choreographer.doFrame(Choreographer.java:550)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.os.Handler.handleCallback(Handler.java:739)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.os.Handler.dispatchMessage(Handler.java:95)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.os.Looper.loop(Looper.java:135)
05-03 13:01:12.949: E/AndroidRuntime(30276): at android.app.ActivityThread.main(ActivityThread.java:5312)
05-03 13:01:12.949: E/AndroidRuntime(30276): at java.lang.reflect.Method.invoke(Native Method)
05-03 13:01:12.949: E/AndroidRuntime(30276): at java.lang.reflect.Method.invoke(Method.java:372)
05-03 13:01:12.949: E/AndroidRuntime(30276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
05-03 13:01:12.949: E/AndroidRuntime(30276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
What can I do to make my layout design, more similar to Clean Master app's layout?
What can I do to make my android (xml) design, more similar to this app screenshot?
Basically I've seen this application screen I liked the look of, and I've attempted to make my design match it as closely as possible. But although my design does look similar, it doesn't look anywhere near as good.
What other changes do you think I should make, to make my design look as good as the screenshot below. My code and a screenshot of my design so far are also below
To be more specific, the parts of the design within the screenshot I'm having difficulty duplicating are:
- keeping the rounded edges to just the top two corners of the blue section
- my percentage bar, looks no where near as good as the original
- The four square white buttons, from the white section of mine look no where near as good. And I can't quite figure out how to fix mine to accomplish the same.
- The font color and style of the original looks fantastic and well mine doesn't
I have made an attempt in each of the above, as you can see below. But Any help would be, much appreciated. Thank You
A screenshot of the app, I'm trying to match design of
A screenshot of my app design so far:
The code for my app design so far:
Activity_main.xml
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
xmlns:andrpod="http://ift.tt/GEGVYd"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="320dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/mainbackground"
android:id="@+id/Main">
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:id="@+id/progressBar"
android:layout_width="240dp"
android:layout_height="240dp"
android:indeterminate="false"
android:max="100"
android:progress="75"
android:progressDrawable="@drawable/style_circular_fill"
android:secondaryProgress="10"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="45%"
android:id="@+id/Percentage"
android:textColor="#fff"
android:textSize="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="127dp"
android:fontFamily="sans-serif-light"
android:textIsSelectable="false"
android:layout_marginLeft="69dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30.93GB/63.57GB"
android:id="@+id/Size"
android:textColor="#fff"
android:textSize="22.5dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="95dp"
android:fontFamily="sans-serif-light"
android:layout_marginLeft="30dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Storage"
android:id="@+id/Type"
android:textColor="#fff"
android:textSize="25dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="57dp"
android:fontFamily="sans-serif-light"
android:layout_marginLeft="69dp" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:id="@+id/progressBar2"
android:layout_width="120dp"
android:layout_height="120dp"
android:indeterminate="false"
android:max="100"
android:progress="75"
android:progressDrawable="@drawable/style_circular_fill"
android:secondaryProgress="10"
android:layout_alignParentEnd="true"
android:layout_marginTop="150dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="77%"
android:id="@+id/RamPercentage"
android:textColor="#fff"
android:textSize="25dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="115dp"
android:fontFamily="sans-serif-light"
android:textIsSelectable="false"
android:layout_marginLeft="300dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Ram"
android:id="@+id/HardwareType"
android:textColor="#fff"
android:textSize="25dp"
android:fontFamily="sans-serif-light"
android:layout_alignBottom="@+id/Type"
android:layout_alignParentEnd="true"
android:layout_marginRight="37.5dp"
android:layout_marginBottom="20dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Vulnerability Scanner"
android:id="@+id/ApplicationTitle"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/Size"
android:focusableInTouchMode="false"
android:textColor="#fff"
android:fontFamily="sans-serif-light"
android:freezesText="false"
android:textIsSelectable="false"
android:textSize="23dp"
android:layout_marginTop="15dp" />
<ImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:id="@+id/imageView5"
android:scaleType="fitXY"
android:layout_marginLeft="310dp"
android:src="@drawable/menu"
android:layout_alignParentTop="true"
android:layout_alignEnd="@+id/progressBar2"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:tint="#fff" />
<LinearLayout
xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="208.5dp"
android:gravity="top"
android:visibility="visible">
<RelativeLayout
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom|end">
<Button
android:id="@+id/add_button"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="@drawable/add_button_selector"
android:gravity="center"
android:stateListAnimator="@null"
android:text="+"
android:textSize="27sp"
android:elevation="3dp"
android:fontFamily="sans-serif-light"
android:textColor="#2C5AA8"
tools:ignore="HardcodedText,UnusedAttribute" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="192dp"
android:layout_height="125dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/buttonshape"
android:id="@+id/Button_A"
android:layout_marginTop="320dp" >
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:id="@+id/imageView"
android:src="@drawable/bin"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="JUNK FILES"
android:id="@+id/textView"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_marginBottom="5dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="190dp"
android:layout_height="125dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/buttonshape"
android:id="@+id/Button_B"
android:layout_marginTop="320dp"
android:layout_marginLeft="192dp" >
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/imageView2"
android:src="@drawable/rocket"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:scaleType="fitXY" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="PHONE BOOST"
android:id="@+id/textView2"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_marginBottom="5dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="192dp"
android:layout_height="125dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/buttonshape"
android:id="@+id/Button_C"
android:layout_marginTop="445dp" >
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/imageView3"
android:src="@drawable/shield"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:scaleType="fitXY" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="ANTIVIRUS"
android:id="@+id/textView3"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_marginBottom="5dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="190dp"
android:layout_height="125dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/buttonshape"
android:id="@+id/Button_D"
android:layout_marginTop="445dp"
android:layout_marginLeft="192dp" >
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/imageView4"
android:src="@drawable/appstore"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:scaleType="fitXY" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="APP MANAGER"
android:id="@+id/textView4"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_marginBottom="5dp" />
</RelativeLayout>
circularmaterialselected.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://ift.tt/nIICcg">
<item>
<layer-list>
<item>
<shape android:shape="oval">
<solid android:color="#08000000"/>
<padding
android:bottom="3px"
android:left="3px"
android:right="3px"
android:top="3px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#09000000"/>
<padding
android:bottom="2px"
android:left="2px"
android:right="2px"
android:top="2px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#10000000"/>
<padding
android:bottom="2px"
android:left="2px"
android:right="2px"
android:top="2px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#11000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#12000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#13000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#14000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#15000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#16000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#17000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
</layer-list>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#E1E1E1"/>
</shape>
</item>
</layer-list>
circularmaterial.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://ift.tt/nIICcg">
<item>
<layer-list>
<item>
<shape android:shape="oval">
<solid android:color="#08000000"/>
<padding
android:bottom="3px"
android:left="3px"
android:right="3px"
android:top="3px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#09000000"/>
<padding
android:bottom="2px"
android:left="2px"
android:right="2px"
android:top="2px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#10000000"/>
<padding
android:bottom="2px"
android:left="2px"
android:right="2px"
android:top="2px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#11000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#12000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#13000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#14000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#15000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#16000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#17000000"/>
<padding
android:bottom="1px"
android:left="1px"
android:right="1px"
android:top="1px"
/>
</shape>
</item>
</layer-list>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#E1E1E1"/>
</shape>
</item>
</layer-list>
buttonshape.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://ift.tt/nIICcg" >
<item>
<shape
android:shape="rectangle">
<stroke android:width="0.9dp" android:color="#000" />
<solid android:color="#FFDDDDDD" />
</shape>
</item>
<item android:top="0.1dp" android:bottom="0.1dp" android:left="0.1dp" android:right="0.1dp">
<shape
android:shape="rectangle">
<stroke android:width="0.9dp" android:color="#FFDDDDDD" />
<solid android:color="#00000000" />
</shape>
</item>
</layer-list>
mainbackground.xml
<shape xmlns:android="http://ift.tt/nIICcg"
android:shape="rectangle" >
<solid android:color="#2C5AA8" />
<corners
android:topLeftRadius="10dp"
android:topRightRadius="10dp" /></shape>
add_button_selector.xml
<selector xmlns:android="http://ift.tt/nIICcg">
<!-- <item android:state_selected="true" android:drawable="@drawable/add_button_selected"/> -->
<item android:state_pressed="true" android:drawable="@drawable/circularmaterialselected"/>
<item android:state_pressed="false" android:drawable="@drawable/circularmaterial"/>
</selector>
style_circular_fill.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://ift.tt/nIICcg" >
<item android:id="@android:id/secondaryProgress">
<rotate
android:fromDegrees="270"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="270" >
<shape
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thicknessRatio="20.0"
android:useLevel="true" >
<gradient
android:centerColor="#A9E2F3"
android:endColor="#A9E2F3"
android:startColor="#A9E2F3"
android:type="sweep" />
</shape>
</rotate>
</item>
<item android:id="@android:id/progress">
<rotate
android:fromDegrees="270"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="270" >
<shape
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thicknessRatio="20.0"
android:useLevel="true" >
<gradient
android:centerColor="#26ce61"
android:endColor="#26ce61"
android:startColor="#26ce61"
android:type="sweep" />
</shape>
</rotate>
</item>
</layer-list>
Android: How to change my action bar background color
I used Android Studio to create a project with activity that uses ListView and a navigation drawer template, I'm targeting API 14+ and I'm testing on Galaxy Note 3 Kitkat - the result of the code below is "Nothing" the action bar color is black (very dark grey) not blue as I intend.
in build.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'}
in AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
in Styles.xml (where I have AppTheme)
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:activatedBackgroundIndicator">@drawable/drawer_list_selector</item>
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@drawable/blue_action_bar_color</item>
</style>
in blue_action_bar_color.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://ift.tt/nIICcg">
<solid android:color="@color/action_bar"/>
</shape>
in colors.xml
<color name="action_bar">#3b5b98</color>
So what am I missing here?
EDIT1:
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
EDIT2:
I can't use
<style name="AppTheme" parent="android:Theme.Holo.Light">
as my application crash with error message:
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
Support libraries 22.1.1 and Drawable Tinting
Two weeks ago google released new support libraries, where the v4 library gives you the possibility to "use" the Lollipop feature of tinting drawables.
However so far I only managed to do this programmatically. There you wrap the drawable object, which basically returns you a new drawable which allows you to tint it.
Question: Now I wanted to ask whether it is possible to tint drawables via xml. The standard Lollipop way won't work with AppCompat.
Year 2015- Is there a way to limit download on Android market by cpu/gpu "power" of device?
I know this has been asked/answered before but these answers are from 2011. It's not good to necro/duplicate of course but things change over 4 yrs sometimes so I don't "think" I am being unreasonable here. Hopefully, things have changed for this question.
Answered 2011 - How to exclude devices with lower GPU in Android?
Answered 2011 - How to exlude all the devices which have low GPU in Android Manifest?
I've looked throught the Android manifesto myself a bit to filter out apps search results by various hardware but there was little about processors, or gpu, etc that I could find to help. I searched google for the past couple hours with not much luck. I have never published to Android market so apologies if this is obvious.
I have a game I am planning to release on the Android market but it is graphically intensive and only higer end devices can run it. I have tried running it on an iPad 2 and it barely works so that is my lowest bench mark for Apple store. I have tried running it on a Galaxy 4 tablet 7.0 (Android OS: v4.4.2 (KitKat), Chipset: Marvell PXA1088, CPU: Quad-core 1.2 GHz) and it is unplayable.
I know I will be cutting out a very large potetnial customer base but I need some way to limit the abilty to download if the device is too slow to run the game.
How can this be achieved? Is there a list of basic Android cpu/gpu performace to help filter if the store route can't be done?
Thanks
How to setImageResource in ListView Android?
I would like to setImageResource to my image in my listView
Here how the listView is shown with information :
ListAdapter adapter = new SimpleAdapter(
MainActivity.this,impatientEventList, R.layout.view_event_entry, new String[] {
"title"
}, new int[] {
R.id.event_title
});
setListAdapter(adapter);
and my ListView entry :
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/event_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="23dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/imageView1"
android:text="Title"
android:textSize="16sp"
android:fontFamily="sans-serif-thin"/>
I don't really know how to put it when I use a List, anyone to help ? :) Thanks by advance!
Dynamically add views to fragment hosted by Viewpager
I'd like to add 7 previously created views dynamically to my viewpager.
What I try to achieve at the end is a part of my screen (50dp height, match_parent width) looking like this.
| VIEW 1 | VIEW 2 |
When I swipe to the right, the displayed items will be VIEW 2 and VIEW 3, next swipe will be VIEW 3 and VIEW 4 and so on.
My problem is that my 7 views are already created in the onCreateView of my main fragment. I'd like to add them dynamically to my fragment defined in the FragmentStatePagerAdapter.
public class MyPagerAdapter extends FragmentStatePagerAdapter {
private View view1Layout;
private View view2Layout;
public MyPagerAdapter(FragmentManager fm, View view1Layout, View view2Layout) {
super(fm);
this.view1Layout = view1Layout;
this.view2Layout = view2Layout;
}
@Override
public Fragment getItem(int position) {
Fragment fragment = new MyFragment();
LinearLayout rootLayout = ((LinearLayout) fragment.getView().getRootView());
switch (position % 7) {
case 0:
rootLayout.addView(view1Layout);
rootLayout.addView(view2Layout);
break;
case 1:
// ....
break;
}
return fragment;
}
@Override
public int getCount() {
return 1000;
}
}
public static class MyFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.layout_dashboard_line, container, false);
}
}
As you can imagine, it will crash when I try to get the rootLayout, as the fragment is not instantiated at this time. Is there a good way to achieve what I want or a workaround if not ?
Thanks !
Using bitmap in external dialog Imageview
As I can assign a bitmap of a previously selected image, a ImageView an external Layout Dialog .. I have this code, which when not assign the layout to strip findViewById returns error, if assign it (which is what I think the problem is) simply nothing happens, not display the image.
Method that selects image gallery
public void selImagen(View v){
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
int code = SELECT_PICTURE;
startActivityForResult(intent, code);
}
method that creates a bitmap image selected and displayed on a imageview
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//The problem is here I think, if so OTHERWISE INDICATE THAT BELONGS TO THIS LAYOUT IMAGEVIEW
LayoutInflater li = LayoutInflater.from(this);
View prompt = li.inflate(R.layout.prod_new_modal, null);
Uri selectedImage = data.getData();
InputStream is;
try {
is = getContentResolver().openInputStream(selectedImage);
BufferedInputStream bis = new BufferedInputStream(is);
final Bitmap bitmap = BitmapFactory.decodeStream(bis);
ImageView imageview = (ImageView)findViewById(R.id.imgView);
imageview.setImageBitmap(bitmap);
} catch (FileNotFoundException e) {
} catch (IOException e) {
e.printStackTrace();
}
}
Using regex to find chars in a string and replace
When returning a string value from an incoming request in my network based app, I have a string like this 'post http://a.com\r\nHost: a.com\r\n'
Issue is that the host is always changing so I need to replace it with my defined host. To accomplish that I tried using regex but am stuck trying to find the 'host:a.com' chars in the string and replacing it with a defined valued.
I tried using this example http://ift.tt/1zohISF changing the pattern compile to :([\\d]+) but it still remains unchanged.
My goal is to replace given chars in a string with a defined value and returning the new string with the defined value. Any pointers?
Editing java files made by cordova to access GPS sensor in Android
I am trying to build a mobile android app with jquery mobile and cordova. I have found that the native GPS sensor cannot be accesses directly by cordova application. Is it possible to edit the java files created by cordova ,so that the sensor can be accessed?
moving Image View from point to another
good morning/evening everyone i want when a particular button clicked, the image view will move from a point in the layout to another point
here's my code
int e = 0 ;
Button d = (Button)findViewById(R.id.button1);
d.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{ TranslateAnimation move = new TranslateAnimation(e,e+1, e, e+1);
move.setDuration(1000 );
move.setFillAfter(true);
image.startAnimation(move);}
});
but when i clicked the button nothing happend ! how to make it work ?
How can I display info from a sensormanager class in an android project?
I have a sensormanager for my temperature sensor, and I used the templat from the android repository:
public class SensorActivity extends Activity, implements SensorEventListener {
private final SensorManager mSensorManager;
private final Sensor mAccelerometer;
public SensorActivity() {
mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
}
protected void onResume() {
super.onResume();
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
}
protected void onPause() {
super.onPause();
mSensorManager.unregisterListener(this);
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
public void onSensorChanged(SensorEvent event) {
}
}
But with temperature instead of accelerometer.
Unfortunately, I have no idea how to get the actual numbers from here to my main activity in a form I can display, preferrably in a way that constantly updates.
Make a POST call every 10 seconds for an infinite time?
How can I make a certain function executed after every 10 seconds for an infinite time?
What I have done till now: I am getting the location values of the user from the App and storing it on the server. I am using a service, so that, the code keeps running for an infinite time, I am using a Broadcast receiver, so that, if the phone is booted, the service should start again and starts sending me the location.
The issue Everything works perfectly fine for about first 10-15 minutes, but, after this, the service gets stopped itself. Also, when the user signs up for the App, authorized tokens are generated. These tokens are also sent in the POST call as one of the parameters, for security purpose. Even these tokens are lost, despite working perfectly fine for the initial 10 minutes. I am storing these tokens in SharedPreferences. Any help in this regard would be highly appreciated.
Maintain fixed ration between LinearLayou and TableLayout height
In the below code, I designed so that linearLayout2 and tableLayout2 should have 1:2 height ratio. linearLayout2 contains 1 imageview and 1 table layout with 4 table rows whereas tableLayout2 contains 8 table rows.
Normally this setup works fine. But if I load a longer image in imageview1, the setup gets messed up with linearLayout2 becomes very long (same size as imageview1), but tableLayout2 srinks to minimum height.
How can I make sure to maintain same 1:2 ratio all the time?
Thanks,
<RelativeLayout xmlns:android="http://ift.tt/nIICcg" xmlns:tools="http://ift.tt/LrGmb4" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ScrollView android:layout_width="match_parent" android:layout_height="fill_parent" android:fillViewport="true" > <LinearLayout android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" > <LinearLayout android:id="@+id/linearLayout2" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="0.33" > <ImageView android:id="@+id/imageview1" android:scaleType="centerInside" android:adjustViewBounds="true" android:layout_width="wrap_content" android:layout_height="fill_parent" /> <TableLayout android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="1" > <TableRow android:layout_width="wrap_content" android:layout_height="0dp" android:layout_weight="1" > .......................................................................... .............................. 4 such TableRow ........................... .......................................................................... </TableLayout> </LinearLayout> <TableLayout android:id="@+id/tableLayout2" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="0.67" android:stretchColumns="1,3" > <TableRow android:layout_width="wrap_content" android:layout_height="0dp" android:layout_weight="1"> .......................................................................... .............................. 8 such TableRow ........................... .......................................................................... </TableRow> </TableLayout> </LinearLayout> </ScrollView> </RelativeLayout>
strange behavior for activity, when generating APK vs testing app
so i have this code in my app, it collects information while the application is not in focus using a "locationListenerFunc = new LocationListener" service, and then when the application resumes focus, it uses this information to display a line on map, WHEN I TEST the application and mimimize it, then opens the application back up, everything works great, the application is in the same state as i left it, and does everything it suppose to do. WHEN I GENERATE APK and test it that way, it works, but when i close it, then open it back up, it sort of restarts itseld, the activity is NOT in the same state as i left it.(further testings show that when i resume the app it goes into the onCreate again, instead of on resume)
does anyone know why does this happening ?
here is my code for the main activity >
package com.greenroad.candidate.assignment;
import android.content.Context;
import android.graphics.Color;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.text.format.Time;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.PolylineOptions;
import java.util.ArrayList;
import java.util.List;
public class MapsActivity extends FragmentActivity {
private GoogleMap mMap; // Might be null if Google Play services APK is not available.
private Button startTrackingButton;
private Button stopTrackingButton;
private TextView mainText;
private Boolean isInPause = false;
private List<LocationItems> locationItemsList = new ArrayList<LocationItems>();
private double ladHistory = 0;
private double logHistory = 0;
private LocationManager manager;
private LocationListener locationListenerFunc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_fragment_layout);
//casting
startTrackingButton = (Button) findViewById(R.id.BTStartTracking);
stopTrackingButton = (Button) findViewById(R.id.BTStopTracking);
mainText = (TextView) findViewById(R.id.TVMainTextView);
stopTrackingButton.setEnabled(false);
//GPS LOCATION MANAGER
manager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
locationListenerFunc = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
///
Log.d("myTag", "onlocation change ?");
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(location.getLatitude(), location.getLongitude()), 13));
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(location.getLatitude(), location.getLongitude())) // Sets the center of the map to location user
.zoom(17) // Sets the zoom
.bearing(90) // Sets the orientation of the camera to east
.tilt(30) // Sets the tilt of the camera to 30 degrees
.build(); // Creates a CameraPosition from the builder
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
//sets text & lat, long>
Time today = new Time(Time.getCurrentTimezone());
today.setToNow();
double Lad = location.getLatitude();
double Long = location.getLongitude();
mainText.setText("lat: " + String.valueOf(Lad) + ", " + "long: " + String.valueOf(Long) + ", last update at: " + today.format("%k:%M:%S"));
//add a line on map
if ((ladHistory != 0) && (logHistory != 0)) {
PolylineOptions line =
new PolylineOptions().add(new LatLng(ladHistory,
logHistory),
new LatLng(location.getLatitude(),
location.getLongitude()))
.width(30).color(Color.RED);
mMap.addPolyline(line);
}
//updates veraibles
ladHistory = location.getLatitude();
logHistory = location.getLongitude();
//handles all polylines lost while application was offline:
if (isInPause == true) {
locationItemsList.add(new LocationItems(location.getLatitude(), location.getLongitude()));
}
///
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
};
//stops tracking button touch listener
stopTrackingButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
//handles the disabling and starting of buttons
stopTrackingButton.setEnabled(false);
startTrackingButton.setEnabled(true);
//removing locaion updates
manager.removeUpdates(locationListenerFunc);
manager = null;
mainText.setText("stopped location update");
}
});
//starts tracking button touch listener
startTrackingButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
//Do stuff here
Time today = new Time(Time.getCurrentTimezone());
today.setToNow();
mainText.setText("location update started at: " + today.format("%k:%M:%S"));
manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
1000, 0, locationListenerFunc);
//handles the disabling and starting of buttons
startTrackingButton.setEnabled(false);
stopTrackingButton.setEnabled(true);
}
});
//setting up map
setUpMapIfNeeded();
}
@Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
isInPause = false;
//repaints all lost points
for (int i = 0; i < locationItemsList.size() - 1; i++) {
LocationItems sourceItem = (LocationItems) locationItemsList.get(i);
LocationItems destinationItem = (LocationItems) locationItemsList.get(i + 1);
PolylineOptions line =
new PolylineOptions().add(new LatLng(sourceItem.getLatiduteVar(),
sourceItem.getLongitudeVar()),
new LatLng(destinationItem.getLatiduteVar(),
destinationItem.getLongitudeVar()))
.width(30).color(Color.RED);
mMap.addPolyline(line);
//zeroes the lists
locationItemsList = new ArrayList<LocationItems>();
}
}
@Override
protected void onPause() {
super.onPause();
isInPause = true;
}
protected void onDestroy() {
super.onDestroy();
manager.removeUpdates(locationListenerFunc);
manager = null;
}
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
centerMapOnMyLocation(); //centers the map on user location
}
}
}
private void centerMapOnMyLocation() {
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
Location location = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria, false));
if (location != null) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(location.getLatitude(), location.getLongitude()), 13));
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(location.getLatitude(), location.getLongitude())) // Sets the center of the map to location user
.zoom(17) // Sets the zoom
.bearing(90) // Sets the orientation of the camera to east
.tilt(30) // Sets the tilt of the camera to 30 degrees
.build(); // Creates a CameraPosition from the builder
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
//sets text >
double Lad = location.getLatitude();
double Long = location.getLongitude();
mainText.setText("lat: " + String.valueOf(Lad) + ", " + "long: " + String.valueOf(Long));
}
}
}
and here is my menifest file >
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
package="com.greenroad.candidate.assignment" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="-------" />
<activity
android:name=".MapsActivity"
android:screenOrientation="portrait"
android:label="@string/title_activity_maps" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
How to add library project to an existing android project in AndroidStudio
how can I add a custom library project (in my example the CuXtomCam library) to an existing android project using Android Studio 1.1?
I've read about changing the build.gradle file. But where should I place the library ressources?
Thank you in advance for all answers and comments!
Android GridView causing view to be on top of ActionBar
I have a view in which I'm creating a popupwindow. In this popupwindow I have a text box (edittext). When clicking to edit the text, the keyboard opens and the whole view goes up, but the top of the view goes under the action bar view. So far so good.
I now have added an empty gridview without any furthur configuration to the popupwindow, and now the same scenario happends but the whole top part of the view goes on top of the action bar view.
Any idea?
Android Studio using variables from one class in another
My basic app idea is drawing on screen. I've got a spinner object to use to select the color of the "pen". I have them set up for a switch case to change "pen" color. The spinner is in my MainActivity class. I've got my "pen" code in a class called Brush_Color.
Here's the code I have for MainActivity thats related to the Spinner. Each case refers to a color in my arrays.xml. The commented out Paint paint = ... is what I was trying to do but had no luck.
public class MainActivity extends ActionBarActivity implements AdapterView.OnItemSelectedListener{
//Paint paint = new Paint(Brush_Choices.this.paint, Brush_Choices.class);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.color_selector, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
}
public void onItemSelected(AdapterView<?> parent, View v, int position, long id){
switch(position) {
case 0:
//paint.setColor(Color.BLACK);
break;
case 1:
//paint.setColor(Color.BLUE);
break;
public void onNothingSelected(AdapterView<?> parent){
}
And then here is the code of my Brush_Color class. I'm trying to access the Paint object from here and use it in my MainActivity class. I've got no idea how to do this though.
Path path = new Path();
SparseArray<PointF> points = new SparseArray<>();
Paint paint = new Paint();
public void onDraw(Canvas canvas){
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(10);
canvas.drawPath(path,paint);
}
How to invoke the android keyboard using JavaScript without a text field?
So I copied one of my small JavaScript games to my android phone and ran it in the browser. The game worked fine, except one fatal flaw: The game requires keyboard input, and it doesn't have a text field.
The game requires the user to type in certain letters, but they don't type it into a text field. I use a keydown event listener to get each key and process it accordingly.
So how do I invoke the android keyboard without having an actual text field?
How to reset widget in Kivy
I have a very simple application having one button and one label. Label have value 0 initially. On each button press, label increase by 1. When label becomes 3, i show a popup with a "play again" button.
Now, i want to reset label to 0.
My Attempt:
#!/usr/bin/kivy
import kivy
kivy.require('1.7.2')
from random import random
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.popup import Popup
from random import random
from random import choice
from kivy.properties import StringProperty
import time
from kivy.clock import Clock
s=0
def my_callback(dt):
mypopup = MyPopup()
return mypopup.show_popup()
def go_to_main(self):
sm.current = 'menu'
global s
s=0
def test(self):
global s
s=0
print s
class MyPopup(Popup):
def show_popup(self):
mytext= str(s)
content = BoxLayout(orientation="vertical")
content.add_widget(Label(text="Game Over", font_size=20))
content.add_widget(Label(text="Score", font_size=20))
content.add_widget(Label(text=mytext, font_size=20))
mybutton_cancel = Button(text="Play Again", size_hint_y=None, height=40)
content.add_widget(mybutton_cancel)
mypopup = Popup(content = content,
title = "oops",
auto_dismiss = False,
size_hint = (.5, .5))
mybutton_cancel.bind(on_release=mypopup.dismiss)
mybutton_cancel.bind(on_release=test)
mypopup.open()
Builder.load_string("""
<MenuScreen>:
GridLayout:
cols: 1
Button:
id: btn_0
text: "press me to increase score"
on_press: root.val0()
Label:
id: score
text:root.get_score()
""")
class MenuScreen(Screen):
def get_score(self):
return str(s)
#on_click of button code
def val0(self):
global s
s=s+1
self.ids['score'].text=str(s)
if(s==3):
Clock.schedule_once(my_callback, 0)
sm = ScreenManager()
sm.add_widget(MenuScreen(name='menu'))
class TestApp(App):
def build(self):
return sm
if __name__ == '__main__':
TestApp().run()
It resets to 0 successfully, i printed it on console to check, but still display as 3. On button press, changes to 1. I want to show it as 0 instead of 3.
Download Files from links that dont end with an extension example www.ex./fff.apk
I want to download files from an server on Android . I tried DownloadFile class and it worked fine but it can only download from links such as www.ex.de/fff.apk meaning only links that ends with file extension. The server where I want to download files has links such as www.fff./ex.php.
mobile OpenCL local memory bank conflict. Why using local memory is slower than does global memory in kernel?
I'm developing face detection app in android platform using OpenCL. Face detection algorithm is based on Viola Jones algorithm. I tried to make Cascade classification step kernel code. and I set classifier data of cascade stage 1 among cascade stages to local memory(__local) because classifier data are used for all work-items.
But, kernel profiling time without using local mem(using global mem) is more faster than that does with using local memory.
__kernel void CASCADE(__read_only image2d_t input_image, __write_only image2d_t output_image,__constant float* classifierMem){
int cascadeLocalSize = get_local_size(0);
__local float localStage1[5];
int localIdx = get_local_id(1)*cascadeLocalSize + get_local_id(0);
if(localIdx<5)
{
int stage1Idx = localIdx + idxNumValStageArray[0]+4;
localStage1[localIdx] = classifierMem[stage1Idx];
}
barrier(CLK_LOCAL_MEM_FENCE);
int gx = get_global_id(0);
int gy = get_global_id(1);
int featureIndex =0;
float featureThres = localStage1[featureIndex++];
float succVal = localStage1[featureIndex++];
float failVal = localStage1[featureIndex++];
float regionValue = localStage1[featureIndex++];
float stageThres = localStage1[featureIndex];
float featureValue += (regionValue < featureThres)?failVal:succVal;
if(featureValue < stageThres)
write_imagef(output_image, (int2)(gx, gy), (0.1));
}
Without using local memory version (original version):
__kernel void CASCADE(__read_only image2d_t input_image, __write_only image2d_t output_image,__constant float* classifierMem){
int gx = get_global_id(0);
int gy = get_global_id(1);
int featureIndex =0;
float featureThres = classifierMem[featureIndex++];
float succVal = classifierMem[featureIndex++];
float failVal = classifierMem[featureIndex++];
float regionValue = classifierMem[featureIndex++];
float stageThres = classifierMem[featureIndex];
float featureValue += (regionValue < featureThres)?failVal:succVal;
if(featureValue < stageThres)
write_imagef(output_image, (int2)(gx, gy), (0.1));
}
Why using local memory version is slower??
Appium TouchAction dont work on real android device
I want to use Appium TouchAction API method tap (Webelement e1), but can't get it to work. The script passes without performing tap action. Appium server and IDE test script are on same machine.
public class TouchTest {
public WebDriver driver;
public MobileDriver driver1;
@BeforeClass
public void setUp() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "5.0");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "4763f751");
capabilities.setCapability("device", "Android");
capabilities.setCapability("appPackage", "com.android.contacts");
capabilities.setCapability("appActivity", "com.android.contacts.activities.PeopleActivity");
//Create RemoteWebDriver instance and connect to the Appium server.
driver = new RemoteWebDriver (new URL("http://ift.tt/1eWSHgW"), capabilities);
}
@Test
public void testCal() throws Exception {
TouchAction action1 = new TouchAction (driver1);
WebElement clk=driver.findElement(By.name("some text here"));
if((clk).isDisplayed())
{ System.out.println("Contact is displayed");} // i do get this message
action1.tap(clk);
}
The directory name of obj/Debug/android/src/{name space} is a MD5 hash?
In Xamarin Android, I am working with a DialogPreference class and need to access the full path of the class from the XML. I was having a hard time doing it and checked the obj/Debug where I found this:
The name of the namespace is "IntervalAndroid", and all the corrosponding files are placed in the directory with the hash name.
What am I doing wrong?
Error debugging and build in Git PowerShell command and Import Android Studio 1.1.0
I want to use Indic-Keyboard github project for build an application. So when I clone it to my repository and try to build I get build failed with an exception that
Cannot evaluate module ime : Configuration with name 'default' not found.
I create my own release key for key store in android studio 1.1.0 according to developer.android.com's suggestion for Signing Your Own App and store it in E:\GitHubCloneProject\AddSubmoduleAndroidStudio\CloneProject\java\keystores\android.jks.
and also set ANDROID_HOME=E:\Android Sdk in my system environment variable by using the following suggestion from stackoverflow.
I follow the procedure for initialize,update and add submodule according to github project "austimkelly/my-android-project/How-to-Use".
When I try to import in my android studio I get the error
Can not invoke method readLine() on null Object.
I'm using gradle 2.2.1.
samedi 2 mai 2015
Saving int variable using SharedPreferences (not working)
I created an app that on button click increases its integer value from 0 by 1. (it's displayed in a textView) What I'm trying to do is to save that int variable so the modified value will remain after restarting the app. I was trying to use these methods, putting them inside onClick(increase) method as well in onCreate but nothing seems to work:
SharedPreferences mPrefs = getSharedPreferences("label", 0);
Integer var = mPrefs.getInt("var", variable);
SharedPreferences.Editor mEditor = mPrefs.edit();
mEditor.putInt("tag", variable).commit();
and also this:
SharedPreferences sharedPref= getSharedPreferences("mypref", 0);
SharedPreferences.Editor editor= sharedPref.edit();
editor.putInt("name", variable);
editor.commit();
getSharedPreferences("name", variable);
After exiting an app and lauching it the value is reseted to 0
Here's full code:
import android.content.SharedPreferences;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
public class TestApp extends ActionBarActivity {
public int variable = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_app);
TextView statnumber = (TextView) findViewById(R.id.number);
statnumber.setText(String.valueOf(variable));
SharedPreferences mPrefs = getSharedPreferences("var", 0);
Integer var = mPrefs.getInt("var", variable);
SharedPreferences.Editor mEditor = mPrefs.edit();
mEditor.putInt("var", variable).commit();
}
public void increase(View view){
TextView statnumber = (TextView) findViewById(R.id.number);
statnumber.setText(String.valueOf(variable = variable + 1));
}
}
Here's what logcat says (probably not important..):
05-02 22:23:53.010 10827-10827/com.rpd.testapp D/OpenGLRenderer﹕ Enabling debug mode 0
05-02 22:24:56.200 11058-11058/com.asd.testapp D/dalvikvm﹕ Late-enabling CheckJNI
05-02 22:24:56.440 11058-11058/com.asd.testapp D/ActivityThread﹕ setTargetHeapUtilization:0.25
05-02 22:24:56.450 11058-11058/com.asd.testapp D/ActivityThread﹕ setTargetHeapIdealFree:8388608
05-02 22:24:56.450 11058-11058/com.asd.testapp D/ActivityThread﹕ setTargetHeapConcurrentStart:2097152
05-02 22:24:56.730 11058-11058/com.asd.testapp I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
05-02 22:24:56.810 11058-11058/com.asd.testapp W/dalvikvm﹕ VFY: unable to resolve virtual method 12212: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
05-02 22:24:56.810 11058-11058/com.asd.testapp D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
05-02 22:24:56.810 11058-11058/com.asd.testapp I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
05-02 22:24:56.810 11058-11058/com.asd.testapp W/dalvikvm﹕ VFY: unable to resolve virtual method 12218: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
05-02 22:24:56.810 11058-11058/com.asd.testapp D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
05-02 22:24:56.810 11058-11058/com.asd.testapp I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
05-02 22:24:56.810 11058-11058/com.asd.testapp W/dalvikvm﹕ VFY: unable to resolve virtual method 9783: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
05-02 22:24:56.810 11058-11058/com.asd.testapp D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e
05-02 22:24:56.900 11058-11058/com.asd.testapp I/dalvikvm﹕ Could not find method android.view.ViewGroup.onRtlPropertiesChanged, referenced from method android.support.v7.widget.Toolbar.onRtlPropertiesChanged
05-02 22:24:56.910 11058-11058/com.asd.testapp W/dalvikvm﹕ VFY: unable to resolve virtual method 12215: Landroid/view/ViewGroup;.onRtlPropertiesChanged (I)V
05-02 22:24:56.910 11058-11058/com.asd.testapp D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0007
05-02 22:24:56.930 11058-11058/com.asd.testapp I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
05-02 22:24:56.930 11058-11058/com.asd.testapp W/dalvikvm﹕ VFY: unable to resolve virtual method 396: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
05-02 22:24:56.930 11058-11058/com.asd.testapp D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
05-02 22:24:56.930 11058-11058/com.asd.testapp I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
05-02 22:24:56.930 11058-11058/com.asd.testapp W/dalvikvm﹕ VFY: unable to resolve virtual method 418: Landroid/content/res/TypedArray;.getType (I)I
05-02 22:24:56.930 11058-11058/com.asd.testapp D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
05-02 22:24:56.930 11058-11058/com.asd.testapp I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawable
05-02 22:24:56.930 11058-11058/com.asd.testapp W/dalvikvm﹕ VFY: unable to resolve virtual method 359: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
05-02 22:24:56.930 11058-11058/com.asd.testapp D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
05-02 22:24:56.940 11058-11058/com.asd.testapp I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawableForDensity
05-02 22:24:56.940 11058-11058/com.asd.testapp W/dalvikvm﹕ VFY: unable to resolve virtual method 361: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
05-02 22:24:56.940 11058-11058/com.asd.testapp D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
05-02 22:24:57.170 11058-11058/com.asd.testapp D/libEGL﹕ loaded /system/lib/egl/libEGL_adreno200.so
05-02 22:24:57.190 11058-11058/com.asd.testapp D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_adreno200.so
05-02 22:24:57.190 11058-11058/com.asd.testapp D/libEGL﹕ loaded /system/lib/egl/libGLESv2_adreno200.so
05-02 22:24:57.200 11058-11058/com.asd.testapp I/Adreno200-EGL﹕ <qeglDrvAPI_eglInitialize:299>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_JB_REL_2.0.3.1_RB1.04.01.01.45.000_msm8625_JB_REL_2.0.3.1_Merge_release_AU (Merge)
It is my first time when I'm creating an app that creates cache so I don't fully understand how it works. Any help appreciated.
Gradle errors while adding dependencies in build.gradle
I've tried to included cards library in my project using the below code in my build.gradle file.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
dependencies {
//Core card library
compile 'com.github.gabrielemariotti.cards:cardslib-core:2.0.1'
//Optional for built-in cards
compile 'com.github.gabrielemariotti.cards:cardslib-cards:2.0.1'
//Optional for RecyclerView
compile 'com.github.gabrielemariotti.cards:cardslib-recyclerview:2.0.1'
//Optional for staggered grid view support
compile 'com.github.gabrielemariotti.cards:cardslib-extra-staggeredgrid:2.0.1'
//Optional for drag and drop support
compile 'com.github.gabrielemariotti.cards:cardslib-extra-dragdrop:2.0.1'
//Optional for twowayview support (coming soon)
//compile 'com.github.gabrielemariotti.cards:cardslib-extra-twoway:2.0.1'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
But when compiling, android studio is throwing up errors as below.
Error:(23, 0) Gradle DSL method not found: 'compile()' Possible causes:
- The project 'cardslib_1' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
- The build file may be missing a Gradle plugin. Apply Gradle plugin
I'm guessing the reason to be gradle version, which is lower in libraries I'm including. How to know the gradle version my dependencies are using and how to adjust them to my project. When I thought to add the libraries, maven has repositories in aar file which I don't think will let you know the gradle version. Thanks for any help in this regards.
Android TTS from code itself - not user input
I want to use the TTS service to speak out text messages I have written in the code itself such as:
header.setText("Hello!");
I saw TTS from user input, but I do not want this.
I have checked these links by the way:
But not really what I want.
Android Execute Multiple AsyncTask Parallely
Hello All I am a bit confuse about execute multiple asynctask parallely in Android
Before Donut it was just single processing means we can execute only one task at a time but later it has changed and we can execute multiple async task parallely, in that case there was also limit to execute the multiple async task that we can execute only 138 Async Task thread at a time other wise it will through exception but later of honeycomb it has changed and we can execute 5 async task at a time and 10 can be in waiting queue, but if we execute more than 15 async task at a time means if I will execute 16 task at a time then it will execute 6 task parallely and 10 will be in queue, it means there will be atleast 10 task in waiting queue to wait for working thread to get finish, and also later in Kitkat it has been changes and it first get the number of processor running currently in Vm and according that it will execute the multiple asynctask.
Now My Questions are that: 1. what is the problem to execute multiple async task parallely. 2. why is the limit to execute only 138 asynctask at a time. 3. why does it differ with the android version. 4. what does it exactly means in kitkat to get number of processor currently running in VM and according that it will execute the asynstask. 5. what does asynstask use in background to track the waiting asynctask and Running Task.
Please Response For My Questions.
How can I sent notification to all my app users at once android?
I want to sent notifications to all my app users, Like some new offers, I tried this tutorial link
This is working, but this is like a messaging system, I have to sent notifications to each users registered separately, How can I sent to all users single notification at once?
Google Glass Take Picture Intent
I'm trying to take a picture with a Google Glass App. Therefore I'm using a SurfaceView which shows the camera preview in the background. The photo is taken with an intent. The problem is that the onActivityResult method belonging to the intent is never called. I've read that this problem is a bug on Google Glass but should be closed with the newer versions of Google Glass.
onCreate Method:
private CameraSurfaceView cameraView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initiate CameraView
cameraView = new CameraSurfaceView(this);
// Set the view
this.setContentView(cameraView);
}
Intent Calling:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_camera:
take picture
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent != null)
{
Toast.makeText(getApplicationContext(), "Taking Picture",
Toast.LENGTH_SHORT).show();
startActivityForResult(intent, TAKE_PICTURE_REQUEST);
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
This all works fine. The user sees the camera preview and when the intent is called a picture will be taken and stored. After that the user sees a prompt "Tap to Accept". After tapping the app ends but the onActivityResult method is never called.
onActivityResult Method.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
Log.i("Camera", "Hello from onActivityResult");
// Handle photos
if (requestCode == TAKE_PICTURE_REQUEST && resultCode == RESULT_OK)
{
String picturePath = data.getStringExtra(Intents.EXTRA_PICTURE_FILE_PATH);
processPictureWhenReady(picturePath);
}
super.onActivityResult(requestCode, resultCode, data);
}
Logcat Log for my application with Log Level "Info"
05-03 08:45:02.328 29785-29785/com.dhbw.charadect I/dalvikvm-heap﹕ Grow heap (frag case) to 5.955MB for 921616-byte allocation
05-03 08:45:03.305 29785-29785/com.dhbw.charadect I/Choreographer﹕ Skipped 51 frames! The application may be doing too much work on its main thread.
05-03 08:45:03.313 29785-29785/com.dhbw.charadect W/Resources﹕ Converting to boolean: TypedValue{t=0x3/d=0x210 "res/anim/decelerate_interpolator.xml" a=1 r=0x10a0006}
05-03 08:45:04.008 29785-29785/com.dhbw.charadect I/Choreographer﹕ Skipped 30 frames! The application may be doing too much work on its main thread.
05-03 08:45:14.414 29785-29797/com.dhbw.charadect I/Camera﹕ Received CAMERA_MSG_RELEASE
Thanks in advance for all comments!
Use Facebook SDK For Invitation Android
I am trying to use the Android SDK to "invite friends', however my code is giving the following error...
"failed to find provider info for com.facebook.katana.provider.attributionid"
Could you please review my code below and help me understand what I am doing wrong.
String appLinkUrl, previewImageUrl;
appLinkUrl = "your app link url";
previewImageUrl = "http://ift.tt/1OiXZai";
if (AppInviteDialog.canShow())
{
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLinkUrl)
.setPreviewImageUrl(previewImageUrl)
.build();
AppInviteDialog appInviteDialog = new AppInviteDialog(MainActivity.this);
appInviteDialog.registerCallback(callbackManager, new FacebookCallback<AppInviteDialog.Result>()
{
@Override
public void onSuccess(AppInviteDialog.Result result)
{
}
@Override
public void onCancel()
{
}
@Override
public void onError(FacebookException e)
{
}
});
appInviteDialog.show(content);
}
How do I get current Unix time in nanoseconds in Android Shell?
I need to get timestamps in nanoseconds in Android shell. Using date command (from busybox and Cyanogenmod) returns to me this:
@A001 # date +%s.%N
1819.N
The only other working option that I found is using www.timeapi.org.
curl -sSw'\n' http://ift.tt/1c8UVjE >> ctime_tar.txt
However, it requires connection and also takes 0.1 seconds to execute.
What can I use? I really need to get time in nanoseconds, especially something I can execute as a single command.
Unable to call the scale() method in Libgdx for android
I've just started learning Libgdx from today by looking at some of the tutorials and find this framework really good, however, I've bumped in a minor problem. I've set up the fonts with the BitmapFont and was trying to use a method to scale the size of the text, however, I cannot find the scale() method. Did I forget to import something ? or pehaps miss something ?
I've imported import com.badlogic.gdx.graphics.g2d.BitmapFont; for the private BitmapFont font; I was able to change the color fo the font by using font.setColor(Color.GREEN); But I'm unable to call some methods to scale the text . Should I import the entire thing ? or should I have added additional libs in the first place ? I've listed all the imports that I have in my activity.
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
How to open a Facebook login session?
I would like to open a Facebook login session in my app, but the only thing I can see in Facebook Developers website is how to login using a Login Button.
I know that there is another way, but I can't find it.
Would you help me?
ERROR :rendering problems The following classes could not be found android.support.v7.internal.widget.ActionBarOverlayLayout
I am just a beginner to android app development. When i created a new project on Android Studio 1.1.0, it gives up this error "rendering problems The following classes could not be found android.support.v7.internal.widget.ActionBarOverlayLayout"
Now i have searched about this on google, and i found possibly 3 solutions given by most of the people.
They say:
-
Either change the api (from preview window pane) from 22 to 21, or
-
Change the App Theme from "Project Theme" to any other theme.
-
be sure to have imported right appcompat-v7 library in your project structure -> dependencies, Refer these steps: Add the support library feature project identifier to the dependencies section. For example, to include the appcompat project add compile "com.android.support:appcompat-v7:18.0.+" to the dependencies section, as shown in the following example:
dependencies { ... compile "com.android.support:appcompat-v7:18.0.+" }
Note: My android support lib is up-to-date (installed it using SDK Manager).
Following first two steps, removed the error. But I feel that these are not the permanent solutions, the Second step seems just like a temporary workaround. I have doubts about the First step also, that if to remove the error, we change api from 22 to 21, then at the end, our app wont work in Android 5.1.1(API 22), it would be restricted to Android 5.0.1 and below only (API 21). Are my doubts valid? Regarding the third step, is it the permanent solution to this problem?
P.S : Sorry for mismatching tags, wasn't allowed to add exact tags due to site reputation
how to retrieve group SMS for all the phones in android?
I have a quick question about group sms.
I have 4 devices like Samsung S4 (5.0),Galaxy Nexus(4.3),LG Nexus(5.0),HTC one(4.4). I am getting individual sms's but unable to get group sms's. so I am trying to check the group SMS columns in the each phone to find an alternative solution but i was able to see different columns for each phone. Do you have any idea about how we can retrieve group SMS for all the phones?
Here is the code i used to get the column names and the data for all the phones.
Uri uriSMSURI = Uri.parse("content://sms/");
String[] projection = { "*" };
Cursor cur = getContentResolver().query(uriSMSURI, projection, null,
null, "date");
while (cur.moveToNext()) {
for(int i=0;i<cur.getColumnCount();i++)
{
try
{
Log.d(cur.getColumnName(i),cur.getString(cur.getColumnIndex(cur.getColumnName(i))));
}
catch(Exception e)
{
}
}
}
Looking forward for help.
Thanks in advance..
Download cover image of an album from app
I am implementing a mp3 player in android using ExoPlayer, the mp3 files I am getting theyr download URL connecting to a cloud and print them in a RecyclerView with an ImageView as MP3 Icon and an EditText where I set the name.
Is there a way to download a cover image from google or a professional website and set the ImageView with that Image ? If the method is taking too many resources I everytime the application start I can upload the file in cloud and taking them next time the app opens.
How to get all the device information that is connected to Wifi network in android
I need to get all the devices information (Ip Address,name, MAC and etc) that is connected to specific(or current connected Wifi network) Wifi network.how can I do this?
Headset control in Android
In my music player program,I want to pause the music when extracting the headset by monitoring the headset broadcast.But when the headset extracted, the music still played about 0.5s and then paused.How can I solve this problem?Please help me!Thanks!
Activity not defined
I have been trying to implement ads for which I have chosen to use leadbolt service but when I try to load ads it gives me error" Ad failed to load - activity not defined", I tried my best to find out where it needs to be defined but I couldn't. Please help me out this time and I know that startsession is deprecated. Here is my activity
public class TopRatedFragment extends Fragment {
private ProgressBar progress;
private WebView myWebView2;
private Menu optionsMenu;
private static final String APP_API_KEY = "xxxxxxxxxxx";
private static final String LOCATION_CODE = "inapp";
public View onCreateView(LayoutInflater inflater, ViewGroup container,
final Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_top_rated, container, false);
String url = "http://example.com";
myWebView2 = (WebView) rootView.findViewById(R.id.webViewTop);
myWebView2.setWebChromeClient(new myWebViewClient());
myWebView2.getSettings().setJavaScriptEnabled(true);
progress = (ProgressBar) rootView.findViewById(R.id.progressBar3);
progress.setMax(100);
setHasOptionsMenu(true);
if(savedInstanceState == null) {
AppTracker.setModuleListener(leadboltListener);
// Initialize Leadbolt SDK
//deprecated
AppTracker.startSession(getActivity(), APP_API_KEY);
myWebView2.loadUrl(url);
}
myWebView2.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView View, String url) {
View.loadUrl(url);
TopRatedFragment.this.progress.setProgress(0);
return true;
}
});
myWebView2.setOnKeyListener(new android.view.View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
WebView webView = (WebView) v;
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (webView.canGoBack()) {
webView.goBack();
return true;
}
break;
}
}
return false;
}
});
return rootView;
}
public AppModuleListener leadboltListener = new AppModuleListener() {
@Override
public void onModuleCached(final String placement) {
Toast.makeText(getActivity(), "Ad successfully cached - " + placement, Toast.LENGTH_SHORT).show();
// Ad has been cached, now enable the Show Ad button
}
@Override
public void onModuleClicked(String placement) {
Toast.makeText(getActivity(), "Ad clicked", Toast.LENGTH_SHORT).show();
}
@Override
public void onModuleClosed(String placement) {
Toast.makeText(getActivity(), "Ad closed", Toast.LENGTH_SHORT).show();
}
@Override
public void onModuleFailed(String placement, String error, boolean isCache) {
if(isCache) {
Toast.makeText(getActivity(), "Ad failed to cache - "+error, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity(), "Ad failed to load - "+error, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onModuleLoaded(String placement) {
Toast.makeText(getActivity(), "Ad displayed", Toast.LENGTH_SHORT).show();
// Ad has been shown, now disable to the Show Ad button
}
@Override
public void onMediaFinished(boolean viewCompleted) {}
};
private class myWebViewClient extends WebChromeClient {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
progress.setProgress(newProgress);
//loadingTitle.setProgress(newProgress);
// hide the progress bar if the loading is complete
if (newProgress == 100) {
progress.setVisibility(View.GONE);
setRefreshActionButtonState(false);
// here i try to display ads.
AppTracker.loadModule(getActivity(), LOCATION_CODE);
} else{
progress.setVisibility(View.VISIBLE);
}
}
}}
Thanks for your time.