Skip to main content

Posts

Showing posts from January 18, 2012

How to call any objective c plugin method on click event of html button

I am new in phonegap development. I have one html page which contains one textfield and one button. I want to call my plugin method -(void)nameOfMethod:( NSMutableArray*)paramArray withDict: (NSMutableDictionary*) options which is inside the my plugin class and it getting text from my html text field and displaying alertview.I don't have have idea how to call this method via a javascript .I did a small part of coding in javascript <head><script type="text/javascript" src="encryptdata.js"></script></head> <body> <input type="password" name="confirmPassword" id="confirmPassword" value="" /> <input type="button" value="FetchR" onclick="fetchRelation()"/> </body> encryptdata.js function fetchRelation() { var getvalue=document.getElementById('confirmPassword').value; //what is next step....... to send the data to the plugin

Need SQLite3 APIS for iPhone

I need to add some Database stuff in my iPhone application. i know how to use Database methods manually. But i want to prebuilt APIs which allows me to create tables, insert, delete and update records according to my tables. So is there any kind of prebuilt APIS for sqlite3 in Iphone. Please guide me if there is any. Thanks alot.

UIScrollView not scrolling although contentSize is smaller than UIImageView

So I have a UIImageView as a subview of UIScrollView, I've set the contentSize to be smaller than the UIImageView width and height, however it doesn't allow me to scroll.. why is this? Here's some code: UIImage * image = [UIImage imageWithData:data]; UIImageView * imgView = [[UIImageView alloc] initWithImage:image]; [imgView setUserInteractionEnabled:YES]; //[imgView setContentMode:UIViewContentModeScaleAspectFill]; [imgView setBackgroundColor:[UIColor clearColor]]; [imgView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; [imgView setFrame:CGRectMake(0, 0, imgView.frame.size.width, imgView.frame.size.height)]; CGRect imgFrame; imgFrame.size.width = originalImageSize.width; imgFrame.size.height = originalImageSize.height; imgFrame.origin.x = imageOriginPoint.x;

How can i get all calendar and its events from iphone app?

Good Day to you. I have used iCal events in my app. I have add events to iCal and retrieve/delete the events from iCal from my sample iPhone app. Now, i want to show all the calendars what are the calendars user synced in their iPhone(Eg : Google calendar). Then i want to retrieve the events from other calendars except iCal. How can i get all the synced calendars from iPhone? I searched my level best in Google but, can't to get right answer. Can you please help me? Thanks in advance.

App crashing in cocos2d app on device when nothing happening

I have a somewhat simple game that I'm making and now that I'm testing what I consider a bare bone version of the app on devices, I keep getting crashes over and over. I'm fairly new at debugging on actual devices, so any help would be great. The really weird part is that it will usually crash when nothing is firing. No touches, no animations, nothing is happening. I've tried running Instruments to check for memory leaks. All I find are two objects that are both created in the menu scene. I'm changing scenes using Game *game = [Game nodeWithPlayers:arr Tutorial:NO]; [[CCDirector sharedDirector] replaceScene:game]; which sends some data (mainly # of players) to the Game scene. I put a comment in the dealloc of my menu scene and it fires, so I know that's happening. The two objects that are reported as memory leaks are my MenuManager object that helps w/ some menu animations and positions in the menu scene, and my SoundManager object which at the moment

Need help programming iOS 5.0 "WeeAppPlugin&rdquo;

I decided today that I'd like to develop a widget for jailbroken iDevices, however I haven't found any guides/tutorials for this. I did, however, find a template of sorts but it used Theos, which I'm unfamiliar with as I use Xcode for my development. Can anyone point me in the direction of a tutorial for this? I know the structure itself is still rough since it's brandnew but I'll take any info that I can find. Thanks for the help!

Delegates in iphone

I am using custom Kal calender view library downloaded from github. I know very well and execute successfully how to create delegate protocol and implement them. But now in my application I have to do, when user click on date that date directly reflect to my UIViewController class. For that scenario I used @protocol delegate method but I got strange problem in it. Please see the following screenshot and suggest me where I am wrong, Then i synthesize my protocol but I got the below error. Why, where I am wrong?

Share Kit Scrolling Porblem

I am working on Share kit in both iOS 4.0 and iOS 5.0. When my twitter page opens it works fine in 4.0 but in iOS 5.0 the navigation bar of twitter page become disturbed when Scroll the Webpage. If any one have any solution, share with me... Thanks in Advance

Delete UITableViewCell and ALL of that cell"s data

I have a UITableViewCell. I can add and subtract 1 from the cell's textLabel and I can also delete the cells. Here is my problem, Lets say i add 5 to the value of the textLabel . And this cell is at the 0 indexPath (The First cell in the table). When I delete this cell and there are now no longer any cells on the table, I add a new cell and this new cell automatically gets the same value as the cell that was just deleted. SO this new cell will have a value of 5 and i want the cell to have a value of 1 just like every cell should when it is added. This only happens when a cell is deleted and a new cell is added at that exact same indexPath. So my question is: do i have to delete this cells "memory" or "data" for this to be fixed? Thanks a bunch for the help! CellForRowAtIndexPath : - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; cell = [

How to programmatic segue from one UIViewController to another without Modal or Push?

If one UIViewController is a login screen, and the next one is the app's home screen, what would be the most optimal way to program the transition. I figure the modal segue class is inappropriate for this situation since ideally the transition to the home screen would be permanent, not temporary. But Push didn't make any sense either, since the login screen isn't a Navigation controller, and that isn't the functionality I'm looking for anyway. What would be the best way approach this specific case? Thanks!

DETECT Speaking Language- iPhone

I can covert the speech that a user spokes to text using Open ears (see http://www.politepix.com/openears/yourapp ). But How i could detect the language which the user speaks is English, french, chinese etc... Is there any method to understand in which language the user speaks? How can i check this.? Any help would be appreciated. Thanks Can I play any thing with this - (NSError *) generateLanguageModelFromArray:(NSArray *)languageModelArray withFilesNamed:(NSString *)fileName;

Can anybody help me in understanding the concept of File Owner in xcode

I am unable to get the concept of File owner in xcode. Whenever I am using a ViewContoller then i specify my viewcontoller file(say MyViewController) as the file owner in the xib. Is this because i am connecting my IBOutlets in the MyViewController to the xib? But if this is the case while creating the app in the main window why we specify UIApplication as the File owner. So i guess it may not be related to the IBOutlets concpet. Even when i am customising the UITableViewCell I am using its file owner as the NSObject andthe file where i am conectingthe IBOutlets as its type. So i ma not clear what file should i specify as the File owner for a xib? Please Help. Thanks in advance

Using EventStore, can I create a new iCal calendary type?

So in my app I rely heavily on iCal, and I can add events using EventStore, but only to the "defaultCalendarForNewEvents". I want to make a new calendar just for the events I create in the app, let's say MyApp calendar, which would behave much like the iCal calendars like "Home", "Work", etc. Is there a way to do this progamatically? Right now, I've tried this: EKEventStore *eventStore = [[EKEventStore alloc] init]; NSArray *calendars = [eventStore calendars]; BOOL calendarHasBeenInitialized = NO; for(NSCalendar *cal in calendars) { if([cal.calendarIdentifier isEqualToString:@"Workout Tracker"]) { calendarHasBeenInitialized = YES; } } if(!calendarHasBeenInitialized) { NSString *string = [[NSString alloc] initWithString:@"Workout Tracker"]; NSCalendar *workoutCalendar = (__bridge NSCalendar *)(CFCalendarCreateWithIdentifier(kCFAllocatorSystemDefault, (__bridge CFStringRef)string)); EKCalendar

Implementing a tableview with multiple labels inside a cell

The tableview I am implementing is a kind of phonebook, where I have an entry(name) and below that I am displaying his/her phone numbers. These data make my cell. An entry(name) can have multiple phone numbers(each phone number displayed in different lines). Against each phone number(in the same line) I have an option to set some status message. How can I implement this. The way I have gone forward is: I have created a 2 labels inside a cell. One for displaying the name and the other for displaying the numbers. These numbers are displayed in a multiline way. The problem I am facing is, adding the status message against each phone number(in the same row of each number). For that I may have to add the status as text in between the phone numbers(displayed in a multiline way) in the same label or I have to add another label inside this label. I am a bit confused regarding, how to go about this. Need help.

storing array of data in database in iphone

I want to store an array of data in database.Suppose i have a module called project(x) wherein 'n' number of testers 'm' number of developers are there. So in database for the project name x,i want to store n testers and m developers.. Can anyone tell me how to store this type of data.

How to wait till the current acitivity is in progress

I am creating a test case which will check for the Android application. It launches the application. It enters the user and pass. I need to check whether it is logged in or not. For that I am trying to get the current activity. If it is logged in, it will show the next activity if not it will show the home activity itself. How to get the current activity or help me in doing this above mentioned option.

PreferenceActivity has missing icon on Honeycomb

I've created a simple PreferenceActivity containing a ListActivity. (code added at the end for completeness) but it shows up differently on a 2.3 device and on a Galaxy Tab 10.1" (Android 3.2) (see images below). My questions are: Can I also get the icon with the right arrow in Honeycomb? Can I avoid the empty black line between the title of the activity and the ListPreference public class TestPreference extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setPreferenceScreen(createPreferenceHierarchy()); } private PreferenceScreen createPreferenceHierarchy() { // Root PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this); /* * select language */ ListPreference listPref = new ListPreference(this); listPref.setKey("Language"); listPref.setEntries(new String[]{"eng", "fra"}); listPref.setE

monkey runner random generation

When I want to input some character I do it like this device.press("0",MonkeyDevice.DOWN_AND_UP) this makes input of char '0', and it works great but the problem is I want to enter random numbers between 0 and 9 for let say 1000 times how can I do this ? how can I play with random generation in monkeyrunner I want randomly to choose between: device.press("0",MonkeyDevice.DOWN_AND_UP) device.press("1",MonkeyDevice.DOWN_AND_UP) device.press("2",MonkeyDevice.DOWN_AND_UP) device.press("3",MonkeyDevice.DOWN_AND_UP) ... device.press("9",MonkeyDevice.DOWN_AND_UP) EDIT I want to do this device.press("Random Number between zero and nine",MonkeyDevice.DOWN_AND_UP) device.press("Random Number between zero and nine",MonkeyDevice.DOWN_AND_UP) device.press("Random Number between zero and nine",MonkeyDevice.DOWN_AND_UP) device.press("Random Number between zero and nine",MonkeyDevi

Implement Custom Numpad for EditText

I have an application with a numpad (keys 0-9, Ok and Delete) that is always visible on screen. When the user sets the focus on an EditText that has an numeric input method, then the key pressed on the numpad should be applied to the focused EditText . My current approach is to set a OnFocusChanged listener on each EditText with numeric input method, and then remember the focused control: EditText txt1 = (EditText) findViewById(R.id.editText1); txt1.setOnFocusChangeListener(new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if(hasFocus) focused = (EditText)v; // focused is a member of the Activity class }}); Then when a numpad key is pressed the key is applied to the focused control. To me this seems a bit complex, is there an easier way that works automagically (without the focus change listener) on all EditText widgets with numeric input method? Secondly, is there a way

Is the android app cache cleared after app force close by os?

im building an android app and i need to save some files locally on the SD card. The question i want to ask is that does the android OS clear the app cache mnt/sdcard/Android/data/app_name/cache/* get cleared after the app is closed by the os due to lack of memory ( sigkill sent) ? In what conditions or when is the cache cleared. If the app needs to save some file safely where should it store them?

Android (native java) - Sliding Drawer - Content (Imageview and Checkbox) click event not firing

In one of the project,we have a sliding panel from the bottom. In which user can choose the checkbox and click the image inside the panel. so i have added a sliding drawer component inside the relative layout. Top view will contain, listview and the bottom it will be a slidingdrawer. We have the handle and content part for the sliding component. Inside the content i have added a checkbox and imageview. I want to listen for those events when user clicks any one of those. I can able to listen for teh sliding drawer events but not the other two click events. DO i miss anything for listening of events inside content part in the sliding drawer. I tried by adding clickable property to true in layout xml. But still the same result. I searched in google, but not able to find the solution. Please let me know, if i am missing anything. <SlidingDrawer android:id="@+id/slidingDrawer1" android:layout_width="match_parent" android:layout_height="w

How to retrieve sms date field in android

I'm new to Android programming and I was writing some test code to retrieve all the sms messages in the inbox using an sms intent. The code I wrote is as follows: Uri uri = Uri.parse("content://sms/inbox"); Cursor c = getContentResolver().query(uri, new String[]{"address","person","date","body"}, null, null, null); c.moveToFirst(); if(c.getCount() > 0){ while(!c.isLast()){ System.out.println(c.getString(c.getColumnIndex("date"))); c.moveToNext(); } } Is this the right way? I see that the value for the date column is retrieved as something like "1326781012725". I want to convert this into a readable format like YYYY-MM-DD.How can I do this? Note that I'm using API version 10 and hence the api - cursor.getType() (that returns the data type of the column) is not available. Thanks.

AppEngine Connected Android Project: sendNoRetry: Unauthorized - need token

i have created a new 'AppEngine Connected Android Project' with the Wizzard and entered my registred Mail-Adress. I changed nothing on the Registration-Code, that is created automatically, but I get the following Error erverytime I try to send a Message: com.google.android.c2dm.server.C2DMessaging sendNoRetry: Unauthorized - need token I tried to create a new dataMessagingToken.txt (create a new Project, with the same Name and replace it in the original one) but that does not work... I hope you can help me. Thank You Tobi

Android dialog not showing on Honeycomb

I'm creating an AlertDialog in my Activity (which is set in Portraid mode in manifest file and in onCreate() ). When I'm testing my application on device there is no problem, but when I test in on Android Emulator 3.0 and I'm in landscape mode, in the beginning it's loading my application for a few milliseconds in landscape mode (I can see that in LogCat messages which I've added to my activity), enter in onResume() method of my activity and shows it on Portrait mode. But during this all I can see in my LogCat an error : Activity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@408512e0 that was originally added here I know why I receive this, but I don't know how exactly I can fix this. Here is how my Alert Dialog looks like : public AlertDialog createDialog(){ final CharSequence[] items = {getString(R.string.phone_memory)+" - "+memorysize+" "+getString(R.string.free_space)+" ", getString(R.st

Hot to work around Canvas.clipPath() that is not supported in android any more

From android 3.0 the clipPath() method is no longer supported in devices with hardware acceleration turned on.(Read this article for more details). I am working with canvas and I need to draw rounded image. Any ideas about how can I do that? *I can't turn the hardware acceleration off, I am looking for other solution. Answered: Tnx @Malcolm for your answer. I found a good example that demonstrate this technique , it's basically a mask.

SQLite and Activity updates

I have a neat, working SQLite database on Android that records species observations. I am then using JSON (successfully) to verify observations entered against a set of parameters on a remote database. On verification, a flag in the database is updated to say that this process has been done. But, when I view my main activity (Text, the values for observations with flags after verification don't update. My activity order is: Main activity (obs = 0 from database) Obs Entry activity Main activity (obs = 1 with flag A from db) Data management activity, verify button Verify done activity, main button Main activity (obs = 1 with flag A from db) If I exit, or leave it for a while, then come back in to Main activity, the database is being polled correctly and obs = 1 with flag B from db. So I know my database is right and the SQL is correct too. Could it be that I'm declaring my buttons at the wrong point for the Activity to correctly resume()? My code

Android - Layout with images

I've been working on this for few days but I couldn't get the layout I need. I would like to have a layout similar to the image below. Can anyone guide me with this ? What kind of layout and view should I use ? Thanks :)

android, uninstall and install into the same activity?

I am trying to do an upgrade version process for apk files ... How can i do to run uninstall and install Intent calls into the same activity? If i do , uninstall intent, Uri packageURI = Uri.parse("package:" + paqueteId); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE,packageURI); startActivityForResult(uninstallIntent, RESULT_OK); is there anyway to wait for the uninstall finish and then continue running the activity code ... and then launch the install intent ??? thank you

Android Contacts: how to get contact list with first name, last name and a picture

Is there a way to get all device contacts (aggregated, not raw) with contact ID, fist/last name, and contact picture? Currently I am using the code below but it does not return structured name: private static final String CONTACTS_SORT_ORDER = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; // all contacts public final String[] columns = { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.PHOTO_THUMBNAIL_URI}; c = contentResolver.query(Contacts.CONTENT_URI, null, null, null, CONTACTS_SORT_ORDER); Thanks

i want to play two files one after another on a single click of Button [closed]

i want to play two files one after another on a single click of Button.Files are in assets folder . if (play) { mp.stop(); mp.release(); mp = null; } btn1.setImageDrawable(getResources().getDrawable(R.drawable.key1)); mp = new MediaPlayer(); try { descriptor = getAssets().openFd("c1.mp3"); descriptor1 = getAssets().openFd("d2.mp3"); mp.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength()); mp.prepare(); mp.start(); mp.setDataSource(descriptor1.getFileDescriptor(), descriptor1.getStartOffset(), descriptor1.getLength()); mp.prepare(); mp.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } play = true

showing menu without pressing menu button

I want to create a menu which must be visible in my all the activities.There are around 5,6 activities in my application. So i created a menu but that menu appears after pressing menu button.I want to appear menu without pressing menu button. Please tell me the code that shows menu on start of any activity. I am giving you image the way menu look like. ![enter image description here][1]

Assets Confusion

I'm utterly confused. There's an 'assets' folder in my project, but the AssetManager does not refer to this folder. So I have three questions: First, where is the folder that AssetManager refers to? Second, how do I put files into that folder? Third, how do I access the files that I put into my project's 'assets' folder? (Corollary question: what is the purpose of this folder if it's not used by AssetManager?) The docs completely fail to clarify these issues. Very frustrating.

apk sign error in Android/Eclipse

I am facing the following error whenever I try to sign the apk with existing key store. Is it an error in the logic of my program or is it because I use an old version of Eclipse? The error is: Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/dstudios/bl/ConnectionManager; ConnectionManager is my class and it is in the bl package.

Android - TabHost

I have a tabhost implemented with three tabs and are functioning. What I wanted to know if there is any way back when to click the same tab is selected, it returns to its initial state (like a reset)? I managed to do this using the method "setOnClickListener" of each tab and start to get a new activity, but it does not matter because I notice the passage of activity. Thanks

How do I change the background color of default keyboard used in an app?

So the app I am making requires a darker keyboard to be used (or else the contrast between content and keyboard is far too high), so I need to change what keyboard appears when I interact with an EditText. I've taken a look at the Android Soft Keyboard , but I'm having a hard time following it. If someone is able to help me with that, it'd be wonderful, though I am hoping there is an easier way out there already. Thanks.

Android code lags due to logging / gc / audioManager

To keep it simple: I'm working on a small app where we want to click several objects after each other. On clicking an object, it is supposed to play a sound. This works well, except that from time to time, the entire app (including LogCat's logging) just freezes for about 5 seconds, after which it seems to catch up. (All threads freeze) With catching up I mean; if you continue clicking during the freeze, after unfreezing, it still knows what to do. The Log is simple: 01-17 14:52:08.292: D/AudioManager(17963): setStreamVolume(streamType:3, index:11, flags:0) 01-17 14:52:08.473: D/dalvikvm(17963): GC_CONCURRENT freed 417K, 48% free 3113K/5895K, external 140K/647K, paused 2ms+4ms 01-17 14:52:09.033: D/AudioManager(17963): setStreamVolume(streamType:3, index:11, flags:0) 01-17 14:52:09.484: D/AudioManager(17963): setStreamVolume(streamType:3, index:11, flags:0) 01-17 14:52:10.174: D/AudioManager(17963): setStreamVolume(streamType:3, index:11, flags:0) 01-17 14:5

Android ImageView onClickListener won"t work

I am using a View Object named CameraView that implements View and uses a Hud-Object to create the HUD for a game. In this Hud-Class i use a LinearLayout to place ImageViews. I want these ImageViews to be clickable and to be able to fire some Code on Click. Thats why I use the onClickListener for each of the ImageViews. But it won't work at all. Here is the specific Code of both classes: CameraView protected void onDraw(Canvas canvas) { //GameTimer hud.draw(canvas); // and make sure to redraw asap invalidate(); } HUD public class Hud{ public TextElement gameTimer; CameraView mCameraView; private HashMap<Integer, Item> mItems = new HashMap<Integer, Item>(); private Integer mScreenWidth; private Integer mScreenHeight; //private ImageView imgView; private HashMap<Integer, ImageView> imgViews = new HashMap<Integer, ImageView>(); private LinearLayout ll; public Hud(CameraView cameraView){ mCameraView = cameraView; mScreenWidth

ON & OFF Android Broadcastreceiver

Im creating an app in which i do a task when i receive a call (detect RINGING state with a BROADCASTRECEIVER ).My question is that,can I register and unregister (literally;ON and OFF) his broadcastreceiver from an activity having 2 buttons;say one for ON and another for OFF? Does it require the BROADCASTRECEIVER to be declared inside the activity?If I do so,can i register and unregister it,via the activity?

Modify android home screen

I am creating an android that acts as a media center. I would like to modify the android home screen. What I want is a customized home screen displaying only my application on booting and never display the default android menu other menu buttons or menu drawer that android has. is it possible. I got a few links: How can I create a custom home-screen replacement application for Android? But is it possible to get what i want please help

Common Code for Activity and PreferenceActivity

I'm using common code in my Activity like this: abstract class CommonCode extends Activity { //Common Code here... } then in my "Activity" I extend CommonCode instead of Activity and it all works fine. My problem arise when I try to use commoncode in a PreferenceActivity, I tried: abstract class CommonCode extends Activity { class CommonCodePreferences extends PreferenceActivity { } //Common Code here... } but it isn't right. How can I do it?

Strong Password for KeyStore

I am developing android apps on my very personal computer. Securing the keystore to sign android apps seems to me to be overkill. Securing is usally a pain, so I would apply it only when I get any realistic advantage. The android docs only talk about other users on the same computer, but that is not valid in my case. Is there any rational need to secure a keystore on a secured personal machine? Is there any rational need to use strong password on a keystore on a secured personal machine?