Ask Question
Hello Friends,
On many requests, today I am going to launch a Android forum page, where you may ask any query related to Android development. Query will be replied by experienced android developers.
Hope you will Enjoy this android forum.
Thanks,
Manish
how to open pdf file in android application
ReplyDeletePlease check answer hope it will help you, you can call that code on button click or any where else. Thanks for being first visitor on "Ask Question" page.
DeleteThanks!
plz rply sooon
ReplyDeletepublic class Welcome extends Activity {
Delete@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
File file = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/personal/xyz.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
}
Hello Sir,
ReplyDeleteMy Question, How to get contact details in our website
using Json, Jquery in phonegap(will not general way in android)
URL : http://www.smartdatainc.com/contact-us.aspx
please reply asap.
Thanks
~Sapan
You want device contacts list to be uploaded on server using REST web service right?
Delete@Gaurav but mind it in phonegap not in android.
DeleteSir,
ReplyDeletePlease post REST based integration in android
parse
please reply asap
Thanks
~Sapan
For rest full web-service integration check this link-
Deletehttp://www.androidhub4you.com/2012/09/consuming-rest-web-services-in-android.html
Hi manish how plz one example how access data from mysql database with tomcat server in android.
ReplyDeleteHere am creating data base but how to connect.
Please write web-services for that data and integrate them in your application. Please read REST,JSON and how to create web-services. If you know PHP,Dot net then it's easy for you to create web-service.
DeleteAnd after that use Async Task to integrate your web-services in your android application.
Check below URLs-
http://www.androidhub4you.com/2012/09/consuming-rest-web-services-in-android.html
http://www.androidhub4you.com/2013/03/main-thread-issue-in-android-async.html
Thanks!
hi sir,
ReplyDeletei want to do xml parsing using dom parsing xml file from sd card.how can................i have look many examples
bt most of them are url parsing,assets folder parsing .........now i want to take backup from url to sd card ........
now i have dun take backup from url to sd card ....bt there is a problem is that .i can not read that xml file from sd card .so can u explain .........plese tell me my mail id"amit.sharma.himcs@gmail.com"
Hi Amit,
DeleteYou can read an xml file using following code:
File fXmlFile = new File("sdcard/myxml.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
//optional, but recommended
//read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
doc.getDocumentElement().normalize();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
NodeList nList = doc.getElementsByTagName("staff");
System.out.println("----------------------------");
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
System.out.println("\nCurrent Element :" + nNode.getNodeName());
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
System.out.println("Staff id : " + eElement.getAttribute("id"));
System.out.println("First Name : " + eElement.getElementsByTagName("firstname").item(0).getTextContent());
System.out.println("Last Name : " + eElement.getElementsByTagName("lastname").item(0).getTextContent());
System.out.println("Nick Name : " + eElement.getElementsByTagName("nickname").item(0).getTextContent());
System.out.println("Salary : " + eElement.getElementsByTagName("salary").item(0).getTextContent());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Hope this will help. Thanks.
Hi sir
ReplyDeleteURL Based Parsing using JSon, Jquery, HTML 5
please one example
Thanks Sapan
sorry dear i have no idea about phone-gap. But if you want json or xml parsing in android i can help you.
DeleteThis comment has been removed by the author.
ReplyDeleteHello Sir ,
ReplyDeleteI am a beginner and I am trying to make a simple traffic jam detection android apps , for highlighting the jammed road, I can't do it properly . So , can you provide me a simple example for Highlighting the roads on the Google map .
you can set zoom over that location...
DeleteHi Ashok,
DeleteAs Manish suggested, you can do that. I am just providing you same in code.
Go through this link:
http://pastie.org/8432886
hope It'll help. Thanks. :)
This comment has been removed by the author.
DeleteHello Dear ! its possible retrieve the data (image , text )from database and shown in different activity in listview Xml ?
ReplyDeleteplease see this link it is same what you are looking for.
Deletehttp://www.androidhub4you.com/2012/09/hello-friends-today-i-am-going-to-share.html
HI,
ReplyDeleteYour posts are really good. I am searching a question but cant find the answer.
Basically I want to push the notifications to android devices, and for that I read your post. But I want to know if there is any other optimized way to send a notification to a number of device.
My applications requirement is to send the notification to every user that have our application installed.
Please post it ASAP.
Thanks.
Hi Vijay,
DeleteMy demo app for testing only, so when i receive any reg-id I just send a message on that device. This is the same code what you are looking for you have to just make small changes in php side.
Do you know php? If yes then good for you else learn it or take help form any php guys. Follow below step-
1)Get reg-id from device and send it on server and keep it in shared preference true so again and again your device did not send reg-id on server.
2)In php side get that reg-id and keep in mysql database.
3)Now you have all registered device in your database, you can send message to all device or selected device.
Thanks!
hey
ReplyDeletei want view PDF in application using jar, i tried a jar called PDF-Viewer.jar but its very slow and some times wont work correctly . can you please suggest me some open source library to implement PDF reader . with some code
Hi Bharath,
DeleteHave you tried anyone of below:
1. https://code.google.com/p/apdfviewer/
2. https://code.google.com/p/droidreader/
3. http://sourceforge.net/p/andpdf/code/HEAD/tree/
4. http://www.pdftron.com/pdfnet/mobile/android_pdf_library.html
Hope this will help. Thanks. :)
What if i want to resume the timer?
ReplyDeleteFor Start timer-
DeletemStartTime = SystemClock.uptimeMillis();
mHandler.postDelayed(mUpdateTimeTask, 0);
For Stop timer-
mTime += millis;
mHandler.removeCallbacks(mUpdateTimeTask);
For resume timer-
mTime = 0;
millis = 0;
mStartTime = SystemClock.uptimeMillis();
Hope it will help you...
Hi sir,
ReplyDeleteAndroid Asset packaging Tools (aapt)
what is aapt .?
what is doing in real scenario
is it compile in resourse File or directly send in to apk
builder
pls explain clearly
Thanks
Sapan
Hi Sapan, I did not got more about aapt on google but its main task is create zip file and view zip,jar,apk file in android. And it also compile resources into binary assets.
Deleteaapt is found in the $ANDROID_HOME/platforms/$SDK/tools/ directory of the SDK.
First congratulations, I wonder if you have any topic on socket by sending txt android and the socket send txt for androd, att
ReplyDeleteyou can use wifi-direct..
DeleteThis comment has been removed by the author.
ReplyDeleteHello sir, I m getting problem which is not solved after lots of try. i have created web service for that i m using eclipse, apache tomcat server and axis2 1.6.2 binary runtime everything is configured properly but when i run project on server it display the web page and service list i.e list of deployed web services in server when i click on service it's not display me method name below it shows me no operation specified error. what is problem there plz, help me . thanks.
ReplyDeleteHi Viral, It is very simple to create axis web-service using eclipse. please try another demo hope that will help you. And axis provide us Graphics Interface for testing your service so please test before iy use. And please check your port number where tomcat is running. check manually it is running or not..
Deletehello sir, i have configured everything properly. so, i have forwarded web page snap shot as following for better understanding to solve issue. i m not getting the method name at bottom that is created in web service class which shows me error as bottom that operation not specified.thanks.
DeleteAvailable services
Version
Service Description : Version
Service EPR : http://localhost:8080/WebApp/services/Version
Service Status : Active
Available Operations
getVersion
Hello
Service Description : Please Type your service description here
Service EPR : http://localhost:8080/WebApp/services/Hello
Service Status : Active
There are no Operations specified
Hello Dear, I don't know why you are facing this problem. Any way have you run any Test web-services yet or not?
Deleteok. thanks.
DeleteHi,
ReplyDeletefirst i thank you for your reply to questions. I have one question.
Where Shared preferences, Content providers will store data. I mean SD card, RAM or phone memory? If you don't mine can you pl explain something about memory in phone.
Hi Subba, Nice question. I am not 100% sure but in my knowledge shared preference used RAM(App internal) memory because
Delete1)Ram use flash memory like copy paste and shared preferences also used for same task.
2)And most important thing if your app got force close then you will loss your all shared preferences data so that mean this data is not in phone memory.
And what about memory? you want know about memory management? sorry dear I don't have more idea about it. But for save data into app you can use below memory-
Shared Preferences-Store private primitive data in key-value pairs.
Internal Storage-Store private data on the device memory.
External Storage-Store public data on the shared external storage.
SQLite Databases-Store structured data in a private database.
Network Connection-Store data on the web with your own network server.
Hope it will help you and please if any thing wrong here so please share your knowledge with us. Your most welcome!
SharedPreferences are stored in an xml file in the app data folder, i.e.
Delete/data/data/YOUR_PACKAGE_NAME/shared_prefs/YOUR_PREFS_NAME.xml
Hi Manish, Thanks for your reply.
ReplyDeleteI agreed your point that shared preferences will store data on RAM. The below statement is not happening in my case. I mean it not clearing shared preferences when we got "Force Close". Can you confirm this once.
2)And most important thing if your app got force close then you will loss your all shared preferences data so that mean this data is not in phone memory.
Regarding memory management i gone through this url http://stackoverflow.com/questions/4634774/android-memory-types-ram-v-internal-memory.
Regards
Subba reddy
yes dear, but its depend upon phone processor. I you have poor memory phone and when it got force close at the time of when it is getting data from preferences it will null all of your data from preferences.
Deleteyou can check below URLs-
http://stackoverflow.com/questions/4801074/shared-preferences-reset-when-the-app-is-force-closed-or-crashes
http://stackoverflow.com/questions/13231515/does-sharedpreferences-become-null-when-application-runs-through-out-of-memory-i
Thanks Manish!
Deletehi i have four edittext then i want to set text in that edittext with numbers
ReplyDeleteThis comment has been removed by the author.
DeleteHi Shanmuga,
DeleteIf I really got you. You want something like a edittext with accepting number values only.
In that case, you can use inputType tag as below. In your xml just put like that
EditText
android:id="@+id/edittext"
android:layout_width="283dip"
android:layout_height="35dip"
android:inputType="number"
Hope this'll help. Thanks. :)
hello sir, i have configured everything properly. so, i have forwarded web page snap shot as following for better understanding to solve issue. i m not getting the method name at bottom that is created in web service class which shows me error as bottom that operation not specified. please give me solution. thanks.
ReplyDeleteAvailable services
Version
Service Description : Version
Service EPR : http://localhost:8080/WebApp/services/Version
Service Status : Active
Available Operations
getVersion
Hello
Service Description : Please Type your service description here
Service EPR : http://localhost:8080/WebApp/services/Hello
Service Status : Active
There are no Operations specified
Read more: http://www.androidhub4you.com/p/ask-question.html#ixzz2k4KX85w5
hi any one plz tell how to make windows phone loading animation in android.......
ReplyDeleteHi Shanmuga,
DeleteFor that you need to learn basics of Animation in android. Following is the reference where you can have idea:
http://www.androidhub4you.com/2012/10/flip-animation-in-android.html
Hope this will help. Thanks. :)
Hi Shanmuga, Please try to put your question with full requirement so any one can understand easily.
DeleteWhat you mean ny " windows phone loading animation"? You want loader like windows-7 on start-up or something else? please explain..
This comment has been removed by the author.
ReplyDeletehi manish
ReplyDeleteI would like to make an icon counter for andoid just like the Email and the Samsung Apps applications i have seen such requests from other developers, but you all say it can't be done.
enter image description here
if so how come those 2 apps and other apps can do it?
do i have to make like more than one icon image and swap them or something?
is it really cant be done and why?
thanks.
How to display balloon counter over application launcher icon on android
DeleteI am not sure, please check this URL hope it will help you.
Deletehttp://stackoverflow.com/questions/17565307/how-to-display-count-of-notifications-in-app-launcher-icon
Hi how to make flip animation between two activities? please anyone tell
ReplyDeleteHi this link did not work for you-
Deletehttp://www.androidhub4you.com/2012/10/flip-animation-in-android.html
?
Hi Sir
ReplyDeletewhat is the difference between Android API and Google API, ?
Thanks
Sapan
This comment has been removed by the author.
DeleteHi Sapan,
DeleteThe google API includes Google Maps and other Google-specific libraries. The Android one only includes core android libraries.
Hello
ReplyDeleteI’m really new in java programming. I’m trying to build an android application that will be enabled by NFC, record sound (during sleep) continuously (in separated files of 1-2 minutes length and then start a new recording file), uploading each one of them (right after it’s recorded) on a server and then deleting them from the phone. Also I want to add a UTC timestamp to every file , to be able to synchronize these sounds recordings with other signals, on the same graph.
I’ve found this (http://androidcodeexamples.blogspot.gr/2012/06/voice-recording-in-android.html) open source app, which records audio. I need to make it to :
1. Start while I put the phone on the NFC
2. Record files with 1-2 minutes max length
3. Upload each one on the server and then delete it from the phone
4. Add UTC timestamps
Could you help me with any of these? Any Help would be appreciated.
Thanks in advance!
1)create an app folder like facebook,yahoo and save your sound file in that folder.
Delete2)for send data on server after 2 min you can you can use alarm-manager, which will stop recording sound after every 1-2 min(what time you set) and use Async task to send that sound on server and onPostExcute method delete that path from sd-card.
3)for UTC time you can follow this link-
http://stackoverflow.com/questions/308683/how-can-i-get-the-current-date-and-time-in-utc-or-gmt-in-java
Thanks for your response!
DeleteAs I said,I'm new in Java,could you suggest me a page which I could have free java lessons and excersises?Should I also have lessons for android?
Hi Manish ! here one doubt Am capturing image via my app , and stored the captured image path in sqlite, and i need to retrieve the image by path ? if its possible
ReplyDeleteThanks
yes sure you can get it but be sure no one remove that image from sd-card.
Deletedo something like that-
final String uploadFilePath = "/mnt/sdcard/DCIM/Camera/";
Uri URI = Uri.parse(uploadFilePath);
imgtest.setImageURI(URI);
Thanks Manish....
DeleteI got , please can u prefer me some links ?
i don't want put more back-link on my blog so please search on google, sure you will got it on stack overflow.
Deletejust search "how to save capture image in app folder and retrive path".
This comment has been removed by the author.
ReplyDeleteI emailed you also :) Hoping for response thanks.
Deleteokay kevin, when i got free time on weekend i will check. well it is simple just parse json data and display :)
DeleteThanks!
I am new to android.I got one problem
ReplyDeletei want to show a popup dialogue when there is no values in spinner.I tried this by using spinner.setOnTouchListener,dialogue appears and data also appers in a spinner,after clicking the spinner again dialogue appears...whenever the spinner data is available I dont want to show again dialogue..how to write the code for this one...
i think you are doing something like that-
ReplyDeletespinnerBlock = (Spinner) findViewById(R.id.spinner_sector);
ArrayAdapter adapter2 = new ArrayAdapter(this,
android.R.layout.simple_spinner_item, blockArray);
right?
so just check for blockArray.size() or lenght what ever available if size is zero so popup else display spinier item :)
Thanks for reply..
ReplyDeleteif(EasternPowerDB.meterno.size()<=0)
{
Log.e("tag66", "no values in db");
if(serviceNo.getCount()<=0)
{
Log.e("tag66", "no valuein sps ");
serviceNo.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if(event.getAction()==MotionEvent.ACTION_DOWN)
{
Log.e("tag66", "touch");
dialog = new Dialog(context);
dialog.setContentView(R.layout.newmeter);
dialog.show();
// dialog.setCanceledOnTouchOutside(true);
dialog.setTitle(" New Meter");
userInput = (EditText) dialog.findViewById(R.id.name_et);
meterNo = (EditText) dialog.findViewById(R.id.Meterno_et);
dialogButton = (Button) dialog.findViewById(R.id.ok_bt);
dialogButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
name = userInput.getText().toString();
meterno = meterNo.getText().toString();
db.addNewMeter(name, meterno);
loadSpinnerData();
dialog.dismiss();
}
});
}
return true;
}
});
}
}
I tried like this dialogue is shown,what my problem is i enter values in a dialogue.i want to show the meterno in a spinner.The values also shown in a spinner,but also shown dialogue.when i go back to the activity and again enter into that activity then only it shows the spinner values.....
I did not understand your code. why you do so complex? just did it in simple way how i tell you..
DeleteI have the forms whenever form submit button clicked that all form data will be stored into one json object and that json object stored in on column of database.again whenever submit the form i have to print the list msg in another activity like your new meter is installed.Just like I have seven forms whenever click those forms that msgs also will be append to previous msgs in listview. here there is no problem to me
ReplyDeleteproblem happends in this
in listview one imageview is there whenever click that image i want to retreive particular msg json object and that object data will be displayed in another activity list
so what problem you are facing? do some thing like that-
Deleteholder.btnEdit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(context,B.class)
//you can pass here that json object in putExtra
startActivity(intent);
}
});
or you can just pass next page that column id and on that page from database retrive detail of that image.
I am installing the apk file in my mobile there is an error (There is a problem parsing package error ) why please help me
ReplyDeletefrom where you trying to install that apk? from email or direct from eclipse? if apk is created is should not give any type of error.
Deletefrom email I am installing the apk.
ReplyDeletewhy apk file is not installed from 4.0 version but it is installed in 2.3.3..
ReplyDeleteif lower version is supported then it should work on higher version. please check your manifest for -
Deleteandroid:minSdkVersion="8"
android:targetSdkVersion="18"
and in your project.properties it should be higher version-
target=android-18
please check and update me i am wondering :)
I tried all these suggestions.till apk is not installing,I searched in some websites they give the suggestions like apply asynchTask on project.Is this correctway or not..please help me....
Deleteyes yes asynchTask is good. please use only this for all long time operation..
Deletehow to apply asynchTask for database
Deletein my list view having text views and image view.I want to highlight only image when i an clicking on image.
ReplyDeleteI tried but whole listview is highlighting.
I think you are trying to highlight listview that's why its happening, please see my this blog-
Deleteand set animation on that imageview.
http://www.androidhub4you.com/2013/02/muftitouch-listview-multi-click.html
when i click the image in a listview i want move to another activity.but what i want to show is when i click the image the image hightlight with colour and move to other activity
DeleteUse this code
Deletepackage com.example.customlistview;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class CustomListViewAdapter extends ArrayAdapter {
Context context;
public CustomListViewAdapter(Context contexts, int resourceId,
List rowItems) {
super(contexts, resourceId, rowItems);
this.context = contexts;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
Bean rowItem = getItem(position);
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item, null);
holder = new ViewHolder();
holder.txtDesc = (TextView) convertView.findViewById(R.id.desc);
holder.txtTitle = (TextView) convertView.findViewById(R.id.title);
holder.imageView = (ImageView) convertView.findViewById(R.id.icon);
holder.imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
arg0.setBackgroundColor(Color.BLACK);// use another colors or use selector in xml file
Intent intent = new Intent(context, Second.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
});
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.txtDesc.setText(rowItem.getDesc());
holder.txtTitle.setText(rowItem.getTitle());
holder.imageView.setImageResource(rowItem.getImageId());
return convertView;
}
private class ViewHolder {
ImageView imageView;
TextView txtTitle;
TextView txtDesc;
}
}
In that program you used "Bean".what is that..could you plz clarify me...
DeleteNothing it's only like list.actually bean is a List type class where getter setter are there. with the help of that we are taking values only.
DeletePrasanna @ instead of using bean you can use List simple which contains data.
Deletehello,
ReplyDeletei m developing an app where if user submits form to my server,i should automatically send an sms containing a random digit number to user.....any idea?
you can use GCM for sending message. when he submit form just send a message using GCM. OR you can purchase any bulk sms pack and send it from server on their device. in this case you have not to do anything all task did by back-end developer.
Deletehow to import library of calendar at eclipse.anybody can help?
ReplyDeletedo you have calendar library?
Delete1) well for importing any type of library project just go to eclipse file menu and then select import option after that you will see a chooser window from where go to general and then select Existing project into workspace and press next button. then browse your project and press finish.
2)now go to your main project properties and and from Android tab select Add option for add library.
=========================
and if you have jar for this just put your jar inside libs folder and right click on your project select Build path and from there Configure Build path.
now go to Add jars button and browse that jar from your libs folder.
Thanks!
I want to localise my application from english to telugu.how to do that...
ReplyDeleteyou have to put telgu words instead of english in string.xml like-
Deletetest change it to-
telgu of test
hi
ReplyDeletetelugu language is not supported in android mobiles.how to do that..I there any plugins/softwares....
what is the problem with this-
Deleteetta undavu?
?
its working man just do it. only value is telgu not key nor java code.
I tried like that ....when I executed it shows only random number......
ReplyDeletei don't know about core telgu but it should work-
Deletestring name="how_are_you">etta undavu?
Hi
ReplyDeletewhat folder name we will take for telugu string.xml.
it is inside your res/values/strings.xml ..
Deletei don't know about core telgu but it should work-
string name="how_are_you">etta undavu?
For this you should use ttf font . download that font and put it into assets folder and call it from your activity something like that-
DeleteTypeface Telugu;
Telugu = Typeface.createFromAsset(getAssets(),"fonts/Tikkana.ttf");
TextView tt = (TextView) v.findViewById(R.id.label);
tt.setTypeface(Telugu);
and for that font you can google.
thank u....
ReplyDeleteI want to show my app in telugu as well as english. it will choosen by users.
ReplyDeletesee below link it will helpful for you
Deletehttp://developer.android.com/training/basics/supporting-devices/languages.html
This comment has been removed by the author.
ReplyDeleteI want to get last row values from sqlite database..what is the query for that?
ReplyDeleteFollow this link it will useful
Deletehttp://stackoverflow.com/questions/9902394/how-to-get-last-record-from-sqlite
I have to show my spinner with image and two textviews.one textview is for to show name and another for to show some number.The image and these textviews are assigned by getting the values from database.how to do that?
ReplyDeleteprasanna @ Please explain what is your actual problem.
DeleteI am loading values to the spinner from database.when I click on the spinner it shows repeated values.when I go back to previous activity and again into spinner activity,at that time when i click the spinner it show only original values......how to refresh the current activity?
ReplyDeleteHi Prasanna
Deletethe problem is with fetching data from database, make sure if it's correct. I'll help more if you show me your code.
use pastie.org for copy-paste code and share the URl here. We'll try to resolve that if it's still the problem in your case..
when you call new activity finish previous activity after that when you click back button from new activity call again previous activity by using Intent.
DeleteIn spinner drop down one image and two textviews after selecting the spinner item I want to get only one textview in spinner
ReplyDeleteThis comment has been removed by the author.
DeleteUse this code change according to your requirement......add images what ever you need
ReplyDeletepublic class MainActivity extends Activity {
public static final String[] titles = new String[] { "Android",
"Java", "Core ", "Oracle" };
public static final String[] descriptions = new String[] {
"It is an aggregate accessory fruit",
"It is the largest herbaceous flowering plant", "Citrus Fruit",
"Mixed Fruits" };
public static final Integer[] images = { R.drawable.sync,
R.drawable.setting, R.drawable.dsc_move_icon, R.drawable.vessel_icon };
ListView listView;
List rowItems;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Spinner endDaySpinner = (Spinner) findViewById(R.id.half_day_spn_end);
rowItems = new ArrayList();
for (int i = 0; i < titles.length; i++) {
Bean item = new Bean(images[i], titles[i], descriptions[i]);
rowItems.add(item);
}
final CustomSpinnerViewAdapter adapterSpinner = new CustomSpinnerViewAdapter(getApplicationContext(), R.layout.list_item1, rowItems);
endDaySpinner.setAdapter(adapterSpinner);
endDaySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView arg0, View arg1,
int arg2, long arg3) {
TextView txtTitle = (TextView) arg0.findViewById(R.id.desc);
txtTitle.setVisibility(View.INVISIBLE);
}
@Override
public void onNothingSelected(AdapterView arg0) {
}
});
}
}
---------------------------------Adapter
public class CustomSpinnerViewAdapter extends ArrayAdapter {
Context context;
String stringValue;
public CustomSpinnerViewAdapter(Context contexts, int resourceId,
List rowItems) {
super(contexts, resourceId, rowItems);
this.context = contexts;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
Bean rowItem = getItem(position);
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item1, null);
holder = new ViewHolder();
holder.txtDesc = (TextView) convertView.findViewById(R.id.desc);
holder.txtTitle = (TextView) convertView.findViewById(R.id.title);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.txtDesc.setText(rowItem.getDesc());
holder.txtTitle.setText(rowItem.getTitle());
return convertView;
}
public View getDropDownView(int position, View convertView, ViewGroup parent) {
final ViewHolder2 holder;
Bean rowItem = getItem(position);
if (convertView == null) {
holder = new ViewHolder2();
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.list_item1, null);
holder.txtDesc = (TextView) convertView.findViewById(R.id.desc);
holder.txtTitle = (TextView) convertView.findViewById(R.id.title);
convertView.setTag(holder);
} else {
holder = (ViewHolder2) convertView.getTag();
}
holder.txtDesc.setText(rowItem.getDesc());
holder.txtTitle.setText(rowItem.getTitle());
holder.txtDesc .setVisibility(View.VISIBLE);
return convertView;
}
private class ViewHolder {
TextView txtTitle;
TextView txtDesc;
}
private class ViewHolder2 {
TextView txtTitle;
TextView txtDesc;
}
}
I hide the textview in my spinner by using setVisibility,but it shows empty .I dont want to show empty to that particular textview.how to do that
ReplyDeleteset visibility gone
DeleteHi,
ReplyDeleteI want to create widget with gridview showing data from webservice, and want to place a button there so if i click button gridview will be loaded by new values from web service....
Please helppppppppp!!!!!!!!!!!
Please check my post for custom gridview and use async task to get data from webservices.and put a refresh button on topbar and on button press again hit server and refresh gridview items.
DeleteHi Sir,
ReplyDeleteI am going to develop an app like feature call( when we set date and time and phone number in database) call automatically based on date and time in database to the given number.
Please help me.....
Hi Talari,
DeletePlease use Broadcast Receiver and AlarmManager for scheduling call.
and for calling you can use following Intent:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + num));
activity.startActivity(intent);
Hope this will help. Thanks :)
Thank u Kumar,
DeleteI have used this one but there is no use if there is any another method.....
please..
Did you put necessary permission in manifest? Because if you did the same, it should work.
Deletehai,
ReplyDeleteI am loading the values to spinner from database.when it is loaded the height of spinner is increased.and also text shown in a spinner is not visible....
hello sir, can you pls. help me on how to implement fisher-yates shuffling algorithm in android? i want to shuffle a set of questions using fisher-yates algorithm.
ReplyDeleteHi Roldan,
DeleteThe Collections, itself has function of shuffling an arraylist as below :
Collections.shuffle(Arrays.asList(array));
But if you want it using Android you can do as follows :
import java.util.*;
class Test
{
public static void main(String args[])
{
int[] solutionArray = { 1, 2, 3, 4, 5, 6, 16, 15, 14, 13, 12, 11 };
shuffleArray(solutionArray);
for (int i = 0; i < solutionArray.length; i++)
{
System.out.print(solutionArray[i] + " ");
}
System.out.println();
}
// Implementing Fisher–Yates shuffle
static void shuffleArray(int[] ar)
{
Random rnd = new Random();
for (int i = ar.length - 1; i > 0; i--)
{
int index = rnd.nextInt(i + 1);
// Simple swap
int a = ar[index];
ar[index] = ar[i];
ar[i] = a;
}
}
}
For definition reference you can see the following link:
http://en.wikipedia.org/wiki/Fisher-Yates_shuffle
for example, i'll have a button as a trigger and then when the user press the button my app will automatically select random question from my set of questions. how can i implement such method? thanks in advance.
DeleteJust make an ArrayList object and add every question to it like below:
DeleteArrayList listOfQuestion = new ArrayList();
listOfQuestion.add("Question1");
listOfQuestion.add("Question2");
listOfQuestion.add("Question3");
listOfQuestion.add("Question4");
listOfQuestion.add("Question5");
Collections.shuffle(listOfQuestion);
Now Print or whatever you want to show that.
for(int i=0; i<listOfQuestion.size(); i++ ){
System.out.println(listOfQuestion.get(i));
}
Now You'll get random output. Hope this'll help, Thanks.
upon creating this list of array, can i also add the fisher-yates algorithm as well? to randomized this list of questions? first i have to create an arraylist of questions and then i will randomized the list using fisher-yates algorithm. hope to help me sir. thnx for the previous post.
Deletehello sir! can you pls. give me a sample working code using fisher-yates shuffling algorithm. for ex. i want to randomly shuffle layouts using android xml layouts. tnx in advance.
DeleteHello there
ReplyDeleteI'm a newbie in programming and I wanna build a sound recording application.
I have a code which is recording sound and puts a timestamp,by using MediaRecorder and Calendar.
I need to change it and make it messure the sound levels.I'll use the getMaxAmplitude method,but this method returns only the last result,before it was called.I think I should use a loop,but the start method is capturing and encoding condinuously.
How can I get the current amplitude,for example in a period of 1 second,on my recording?
Thanks
Hi Sir,
ReplyDeleteI have 4fields(Message , Phone Number , Date , and Time) in Sqlite Data Base . I want get Date and time from Data Base and compare the date and time with Current Date and Time and forward a call to the phone number. How it possible and how to Compare date and time with current date and time?
please help me
use something like this query-
DeleteString selectquery = "select price from table_income WHERE date BETWEEN "
+ "'" + dateFrom + "'" + " AND " + "'" + dateTo + "'";
how to add checkboxes to spinner....
ReplyDeleteJust try to create custom view for your spinner. I have no code and no idea about that. Sorry :)
DeleteAlready I have post custom spinner please go through above code, add only check boxes in that layout which is exist in adapter.
Deletehow to refer the checkbox value on another activity on android??
ReplyDeleteRefer this post-
Deletehttp://www.androidhub4you.com/2013/09/android-dynamic-check-box-example-check.html
And for send data to next page just use intent.putExtra(key,value);
and get on next page..
Hi Manish,
ReplyDeleteI had an urgent requirement. The requirement is when i open my application i need to get the layout of Edit text and and Button but the Edit text is to be disable. when i click the Button then only it will get enable. I need sample source code for that. Can you please help me?
yes sure just follow these steps-
ReplyDelete1)go to your layout file and on edittext android:setVisbility="invisible"
2)in your Activity class create onClickListner of button and on click that button enable the edit text-
EditText e=(EditText)findViewById(R.id.editText1);
e.setVisibility(View.VISIBLE);
I have just give an idea,you have to implement it..
How to parse this:
ReplyDelete{
"query": {
"count": 4,
"created": "2013-12-17T04:10:35Z",
"lang": "en-US",
"results": {
"quote": [
{
"symbol": "YHOO",
"Ask": "39.79",
"AverageDailyVolume": "20313600",
"Bid": "39.60",
"AskRealtime": "39.79",
"BidRealtime": "39.60",
"BookValue": "12.333",
}
]
}
}
}
try {
DeleteJSONObject response = json.getJSONObject("query");
JSONObject status = response.getJSONObject("results");
JSONArray quoteArray = status.getJSONArray("quote");
for (int i = 0; i < quoteArray.length(); i++) {
String symobol = quoteArray.getJSONObject(i).getString("symbol");
String ask = quoteArray.getJSONObject(i).getString("Ask");
String avgDailyVol = quoteArray.getJSONObject(i).getString("AverageDailyVolume");
//do same for all values
System.out.println(symobol+ask+avgDailyVol);
}
}
} catch (JSONException e) {
// TODO: handle exception
}
will u please help me to create geofences in android using geofence builder???
ReplyDeletePlease check android doc-
Deletehttp://developer.android.com/training/location/geofencing.html
Thanks for help..it works for me.
ReplyDeleteCould you please tell me how can i get national real time stock feeding?
What you mean by stock feeding? Are you working on Stock Market app?
DeleteYes
DeleteOkay great but I am sorry dear i don't have idea about this. You can ask to your client to provide API for this.
DeleteThis comment has been removed by the author.
DeleteHave you any idea about how to set spinner's default value in android like --select Item--
Deletehi sir i amworkong on braille touch in android by using multitouch plz help me...
ReplyDeleteSorry Muttahir, No Idea..
DeleteThis comment has been removed by the author.
ReplyDeletewhat is the difference between Google api 2.3 and Android 2.3. Can you explain me pls?
ReplyDeleteor
what is difference b/w Google api and Android api
Basically Google API have all feature of normal Android API of same version like 2.3, 4.1 etc but only main difference is that its have some extra Google API(JAR,Plugin) like Google map etc.
DeleteBut now in these days Google provide us Google map version-2 so you don't need Google API just import Google Play Services library.
Google play library have all in one like map,ad-mob,google account detail etc.
how to save value of radio group to string when using the database MySQL....? thanks
ReplyDeleteRefer to Manish blog for creating radio group and add below code inside for loop every value store in arrayList after that you can store all the values into database.Insert data into database code given by manish.
Deleterb[i].setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
String s = ((RadioButton) view).getText().toString();
Toast.makeText(MainActivity.this, "This is: " + s,
Toast.LENGTH_LONG).show();
arrayList.add(s);// this arrayList will hold selection value
}
});
Plzz tell me how you came across the problem of google play service out of date problemm??? do u use eclipse??
ReplyDeleteYes Anirban I am using eclipse. so just update your Google Play Services Lib with new one. Any issue?
DeleteYes here some extra features now like @Integer and all.Now you can use your lib for ad-mob,analytic,Google-map,in-app-purchase and all. means one lib all solution.
hello, how to create a view dynamically.because i want to show so much data from web service.i want to display this data into a horizontal scroll view.is this possible..like as when in web development it is display in table format.i want this in alist view. but more data. is not possible for this.
ReplyDeleteplease rerply to my mail..kaliprasanna007@gmail.com..plz,.,.
Dear Please See Manish blog created Radio Group dynamically.
DeleteSet in layout HorizontalScrollView instead of ScrollView and in LinearLayout set Orientation horizontal.
According to your requirement you can add other view Which you have required.
yes Ajit is right. you can use these post too-
Deletehttp://www.androidhub4you.com/2012/09/dynamically-view-designing-in-android.html
http://www.androidhub4you.com/2012/07/dynamic-swipe-view-demo-in-android.html
http://www.androidhub4you.com/2013/09/android-dynamic-check-box-example-check.html
http://www.androidhub4you.com/2013/09/dynamic-list-view-demo-in-android.html
Hope above link will help you.
I m creating an online application for clothing store, I don't know which database to use for images and how to link it to the application?
ReplyDeletewhen you are talking about "online" that mean your all data should be on server and you can use any database like mysql,sql-server etc. And for images use a folder and put then there and their references(name,id) inside database.
DeleteUse web-services for getting all record from server and display them in your mobile phone.
how to implement the ocr in android
ReplyDeletePlease check on stackoverflow there are many code related to OCR implementation.
DeleteHow i Can run my activity in background
ReplyDeletepackage com.example.swapnil;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.gsm.SmsManager;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewDebug.FlagToString;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
@SuppressWarnings("deprecation")
public class MainActivity extends Activity {
private EditText phoneNoEditText;
private Button addButton;
private TextView phonneNoTextView;
String pno;
String msg = "Hello";
// ArrayList no = new ArrayList();
// android.widget.ArrayAdapter adapter;
String[] smsnumbers = new String[] { "9028462077", "9765862351" };
//String[] smsnumbers = new String[5];
// int smsnumbers[]=new int[5];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// new AsyncTaskEx().execute();
// Intent intent = new Intent(MainActivity.this, MyService.class);
// startService(intent);
//
Intent service = new Intent();
service.setAction("com.myapp.MyService");
this.startService(service);
// setContentView(R.layout.activity_main);
initCOmponents();
registerEvents();
}
private void initCOmponents() {
phoneNoEditText = (EditText) findViewById(R.id.phoneNoEditText);
addButton = (Button) findViewById(R.id.addButton);
phonneNoTextView = (TextView) findViewById(R.id.phoneNoTextView);
}
private void registerEvents() {
// TODO Auto-generated method stub
addButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
addButtonOnClick(v);
}
});
}
protected void addButtonOnClick(View v) {
// TODO Auto-generated method stub
String no = phoneNoEditText.getText().toString().trim();
for(int i=0;i<smsnumbers.length;i++){
smsnumbers.equals(smsnumbers);
smsnumbers[i] = no;
phonneNoTextView.setText(smsnumbers[i]);
Toast.makeText(this, "No ADded" +smsnumbers[i], Toast.LENGTH_LONG).show();
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_POWER) {
Toast.makeText(getApplicationContext(), "KEYCODE_POWER_BUTTONPRESSED",Toast.LENGTH_LONG).show();
for (int i = 0; i < smsnumbers.length; i++) {
SmsManager.getDefault().sendTextMessage(smsnumbers[i], null,
"Hello", null, null);
Toast.makeText(getApplicationContext(), "Message Sent",Toast.LENGTH_LONG).show();
}
}
// TODO Auto-generated method stub
return super.onKeyDown(keyCode, event);
}
// @Override
// public boolean onKeyPress(int keyCode, KeyEvent event) {
// // TODO Auto-generated method stub
// if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
// {
// Toast.makeText(getApplicationContext(), "KEYCODE_VOLUME_DOWN",
// Toast.LENGTH_LONG).show();
// for(int i = 0; i<smsnumbers.length;i++){
// SmsManager.getDefault().sendTextMessage(smsnumbers[i], null, "Hello",
// null,null);
// Toast.makeText(getApplicationContext(), "Message Sent",
// Toast.LENGTH_LONG).show();
// }
//
//
// // String toNumbers = "";
// // for ( String s : no)
// // {
// // toNumbers = toNumbers + s + ";";
// // }
// // toNumbers = toNumbers.substring(0, toNumbers.length() - 1);
// // String message= "this is a custom message";
// //
// // Uri sendSmsTo = Uri.parse("smsto:" + toNumbers);
// // Intent intent = new Intent(
// // android.content.Intent.ACTION_SENDTO, sendSmsTo);
// // intent.putExtra("sms_body", message);
// // startActivity(intent);
// }
// return super.onKeyLongPress(keyCode, event);
// }
}
Can Anybody send me the code to run this in backround also
Deletewhy do you want run your activity in background? Just run any method or particular task in background using Services.
DeleteI want fire an event in bacground by pressing power button ,it will send sms automatically by accepting no.s through my activity
DeleteLike sos button
give me soluton for that
Deleteuse Alarm manager it will work in background..
Deletehi sir,
ReplyDeletei have an calendar app which you designed in this website..i want to add events for particular date like 9-10 meeting
10-11 jogging like that..how to do this
Sorry dear we don't have code for this. You have to some hard work on that.
Delete1)Just change color of that day which dates have event.
2)below of calendar display that events on tab that events.
HI Manish ,
ReplyDeletei am very impressed by the way you have organised the things in ur site .just need some info related to FM application.as per my knowledge concern we dont have any API in android to create FM application for which we need to use 3rd party library .do u have any such Fm sample code and if you can share that i ll be glad to you.
Thanks in advance
Hi Arun thanks for your nice comment. And yes you are right we don't have any API for FM application. It is provided by company manufacture with mobile device like Samsung, HTC etc.
DeleteMay be here some third party library available in market but they are not good i think.If you really want to work on them you need some R&D on firmware. Just override your OS is option in my knowledge.
Well never I have worked on this label so I have no code. Sorry and best of luck for your project. And if you got anything please let me know , it will help me one day.
Thanks!
Hi Manish,
ReplyDeleteThis is vindhya.I need one help.Now I am doing android application .The task is the user should have an option to point and draw a circle of fixed size, when touched at a given
point
SAVE button saves the edited image as a png file in SD card in folder called “/Dev/”
UNDO undoes the previous edit to the image
Hello Vindhya,
DeletePlease give me some time, I am not sure but I have some code related to paint in Android so I will send you hope it will help you.. But please keep trying at your end, I will check today let you know the result.
Thanks Manish.I am keep trying.
Deletemanish , I am waiting for ur reply.......
DeleteHi Manish,
DeleteI saw that code.But how to get only edited image ?this is code for capturing image and showing it is as circle image.but i need only selected portion..any idea?
Hello,
ReplyDeleteHow can i show song lyrics in player?
thank you
song lyrics in listview?
Deletei want to show full song lyrics when song starts playing?
ReplyDeleteSorry Priyal, i have no idea about this. May be speech recognition will help you please try this.
Deletehow to copy the images from one folder to another folder in android....
ReplyDeletethrough code? see this snip of code hope it will help you-
Deletetry {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String sourceImagePath= "/path/to/source/file.jpg";
String destinationImagePath= "/path/to/destination/file.jpg";
File source= new File(data, souceImagePath);
File destination= new File(sd, destinationImagePath);
if (source.exists()) {
FileChannel src = new FileInputStream(source).getChannel();
FileChannel dst = new FileOutputStream(destination).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
}
} catch (Exception e) {}
my app is a simple gallery of smiley for chat. i want to perform for other app to attach image from my app.it's my code but it's not work.please help me.it's very important for me.
ReplyDeleteFile f = new File(Environment.getExternalStorageDirectory(), "/SmileyChat/Fun/fun001.jpg");
Uri uri = Uri.fromFile(f);
if(f.exists()) Toast.makeText(getApplicationContext(),"it's ok",Toast.LENGTH_SHORT).show();
Intent in=new Intent(Intent.ACTION_SEND);
in.setType("image/*");
in.putExtra(Intent.EXTRA_STREAM,uri);
setResult(Activity.RESULT_OK,in);
finish();
So you want send image from your app to another application? Have you achieve any thing positive?
Deletehi manish,
ReplyDeleteI want to develop a video application.in this on basis of enter word search video from youtube.any suggestion and example regarding this.plz help me
Please check you-tube developer API i think they have any api for search query..
DeleteThis comment has been removed by the author.
ReplyDeletehello,
ReplyDeleteI am using gridview and in gridview i have image ,text,and checkbox.i want to show all the selcted checkbox text.can you please give me some idea.i used baseadapter for this
Thank you
I think in your baseadapter class on item check you can add that item in any array-list and on un-checked remove from there. And send that list to where you want.
Deletethank you..
DeleteHow can i get string value from dialog on button click in mainactivity .
hi sir am bignnier level developer so pls give some easy tutoril sir
ReplyDeleteI have many demo app on my blog you can try them and you can read android developer blog too..
Deletehttp://developer.android.com/samples/index.html