Search Results

Search found 18766 results on 751 pages for 'me again'.

Page 6/751 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Background Activity for Map in Android started again if phone orientation is changed

    - by Dave
    Hi, i've developed an android app that's fetches an xml file and displays this data via several markers on the map. This works fine so far. The problem right now is that when i switch the orientation of the phone (portrait-landscape or vice versa) the markers disappear for a small moment, the xml processing is started again and then they reappear. Is there a way to prevent this re-loading of the file? It only takes about 2-3 seconds..so no big deal, but still disturbing

    Read the article

  • Unlock device, display a text, then lock again

    - by Waza_Be
    For the need of my application, I need to display a message on the screen even if the lockscreen is enabled, then wait 3 seconds, than I have to lock again the phone as I don't want it to make unwanted phone calls in your pockets. First part is easy: if (PreferenceManager.getDefaultSharedPreferences( getBaseContext()).getBoolean("wake", false)) { KeyguardManager kgm = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); boolean isKeyguardUp = kgm.inKeyguardRestrictedInputMode(); WakeLocker.acquire(ProtoBenService.this); Intent myIntent = new Intent(ProtoBenService.this,LockActivity.class); myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (isKeyguardUp) { ProtoBenService.this.startActivity(myIntent); } else Toast.makeText(ProtoBenService.this.getBaseContext(), intention, Toast.LENGTH_LONG).show(); WakeLocker.release(); } With this class: public abstract class WakeLocker { private static PowerManager.WakeLock wakeLock; public static void acquire(Context ctx) { if (wakeLock != null) wakeLock.release(); PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "CobeIm"); wakeLock.acquire(); } public static void release() { if (wakeLock != null) wakeLock.release(); wakeLock = null; } } And the Activity: public class LockActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); TextView tv = new TextView(this); tv.setText("This is working!"); tv.setTextSize(45); setContentView(tv); Runnable mRunnable; Handler mHandler = new Handler(); mRunnable = new Runnable() { @Override public void run() { LockActivity.this.finish(); } }; mHandler.postDelayed(mRunnable, 3 * 1000); } } So, this is nice, the phone can display my text! The only problem comes when I want to lock again the phone, it seems that locking the phone is protected by the system... Programmatically turning off the screen and locking the phone how to lock the android programatically I think that my users won't understand the Device Admin and won't be able to activate it. Is there any workaround to lock the screen without the Device Admin stuff?

    Read the article

  • C++ - getline() keeps reading the same line over and over again for some reason

    - by Jammanuser
    I am wondering WTF my while loop which calls istream& getline ( istream& is, string& str ); keeps reading the same line again. I have the following while loop (nested down several levels of other while loops and if statements) which calls getline, but my output statement which is the first code line in the while loop's block of code tells me it is reading the same line over and over again, which explains why my output file doesn't contain the right data when my program is finished. while (getline(file_handle, buffer_str)) { cout<< buffer_str <<endl; cin.get(); if ((buffer_str.find(';', 0) != string::npos) && (buffer_str.find('\"', 0) != string::npos)) { //we're now at the end of the 'exc' initialiation statement buffer_str.erase(buffer_str.size() - 2, 1); buffer_str += '\n'; for (size_t i = 0; i < pos; i++) { buffer_str += ' '; } buffer_str += "throw(exc);\n"; for (size_t i = 0; i < (pos - 3); i++) { buffer_str += ' '; } buffer_str += '}'; } else if (buffer_str.find(search_str6, 0) != string::npos) { //we're now at the second problem line of the first case buffer_str += " {\n"; output_str += buffer_str; output_str += '\n'; getline(file_handle, buffer_str); //We're now at the beginning of the 'exc' initialiation statement output_str += buffer_str; output_str += '\n'; while (getline(file_handle, buffer_str)) { if ((buffer_str.find(';', 0) != string::npos) && (buffer_str.find('\"', 0) != string::npos)) { //we're now at the end of the 'exc' initialiation statement buffer_str.erase(buffer_str.size() - 2, 1); buffer_str += '\n'; for (size_t i = 0; i < pos; i++) { buffer_str += ' '; } buffer_str += "throw(exc);\n"; for (size_t i = 0; i < (pos - 3); i++) { buffer_str += ' '; } buffer_str += '}'; } output_str += buffer_str; output_str += '\n'; if (buffer_str.find("return", 0) != string::npos) { getline(file_handle, buffer_str); output_str += buffer_str; output_str += '\n'; about_to_break = true; break; //out of this while loop } } } if (about_to_break) { break; //out of the level 3 while loop (execution then goes back up to beginning of level 2 while loop) } output_str += buffer_str; output_str += '\n'; } Because of this problem, my if statement and then my else statement in my loop are not functioning as they should, and it doesn't break out of that loop when it should (though it eventually does break out of it, but I don't know exactly how yet). Anyone have any idea what could be causing this problem?? Thanks in advance.

    Read the article

  • WPF 3D - converting from Point2D to Point3D and back again

    - by DanM
    I'm new to WPF 3D, so I may just be missing something obvious, but how would I go about converting from a 2D coordinate to a 3D coordinate and back again? I'd like the 2D coordinate to be the location measured from the upper-left corner of Viewport3D and the 3D coordinate to be the location relative to the origin (0, 0, 0) of the 3D world. The conversion functions should have these signatures: public Point3D Point2DAndWorldZToPoint3D(Point2D point2D, double worldZ) // usually I want to know where a 2D point will be on the ground plane // so worldZ will usually be zero (but not always) public Point2D Point3DToPoint2D(Point3D point3D) I found this related question, but it only addresses conversion from 3D to 2D (not the reverse), and I'm not sure if the answers are up-to-date. Note, I'm currently using .NET 3.5, but if there are improvements in .NET 4.0 that would help me, please let me know.

    Read the article

  • Page upload data again on page refresh in ASP.NET

    - by Etienne
    For some reason when the user click on the submit button and he re-fresh the page the same data get's uploaded again to my SQL Server 2005 database. I do not what this to happen........... Why is this happening? I am making use of a SQL Data Source!! My code Try 'See if user typed the correct code. If Me.txtSecurity.Text = Session("Captcha") Then If Session("NotifyMe") = "Yes" Then SendEmailNS() End If RaterRate.Insert() RaterRate.Update() DisableItems() lblResultNS.Text = "Thank you for leaving a comment" LoadCompanyList() LoadRateRecords() txtCommentNS.Text = "" txtSecurity.Text = "" lblResultNS.Focus() Else Session("Captcha") = GenerateCAPTCHACode() txtSecurity.Text = "" txtSecurity.Focus() Validator10.Validate() End If Catch ex As Exception lblResultNS.Visible = True lblResultNS.Text = ex.Message.ToString lblResultNS.Focus() End Try

    Read the article

  • Jquery callback function executes over and over again...

    - by Pandiya Chendur
    This my jquery function, function getRecordspage(curPage, pagSize) { // code here $(".pager").pagination(strarr[1], { callback: function() { getRecordspage(2, 5);},current_page: curPage - 1, items_per_page:'5', num_display_entries: '5', next_text: 'Next', prev_text: 'Prev', num_edge_entries: '1' }); } and i call this jquery function, <script type="text/javascript"> $(document).ready(function() { getRecordspage(1, 5); }); </script> As you see my It works fine for 1st time and my callback function is configured to the current function itself... when it gets called the callback gets executed over and over again.... How can i prevent this? Any suggestion....

    Read the article

  • Keyboard in HTML text-input disappear when WebView call 'loadUrl' again

    - by Jr.
    Hi there, I use WebView for my Androind App. I got a problem and request a solution for help. There is a textfield in the HTML page. When it gets 'focus' and then I call mWebView.setFocusableInTouchMode(true); in Java code so that the Android soft-keyboard will pop-up to let me key in. The problem is I need using multi-thread for some processes in Java and call mWebView.loadUrl(strJSCall); as callback to execute JavaScript function, but the keyboard gets hidden! The way I try is to force the keyboard to show again. But how can the keyboard always show when 'loadUrl' is called? Dose anyone meet the same issue and solve it already? Sincerely, Jr.

    Read the article

  • Program output to file in Java (and reading it again)

    - by Cohagen
    I have a large main method in an IO class which creates objects from four different classes in my program (which all use one another to some extent). My main method takes all info in using a scanner, from the console window, and uses this info to call the constructors and methods in the other classes. As this is my first full program in Java I have been focussed on making the main method work via the console, without properly considering file input and output. I cannot see an easy way of making that work now. Ideally what I require is some way of writing everything I input to the console while running the main method to a file, in a format that can be read again and inputed back through the main method? I have refrained from posting the main method as it is 250+ lines long, but will post any relevant parts of it if required. Any help appreciated

    Read the article

  • 'echo' or drop out of 'programming' write HTML then start PHP code again

    - by thecoshman
    For the most part, when I want to display some HTML code to be actually rendered I would use a 'close PHP' tag, write the HTML, then open the PHP again. eg <?php // some php code ?> <p>HTML that I want displayed</p> <?php // more php code ?> But I have seen lots of people who would just use echo instead, so they would have done the above something like <?php // some php code echo("<p>HTML that I want displayed</p>"); // more php code ?> Is their any performance hit for dropping out and back in like that? I would assume not as the PHP engine would have to process the entire file either way. What about when you use the echo function in the way that dose not look like a function, eg echo "<p>HTML that I want displayed</p>" I would hope that this is purely a matter of taste, but I would like to know if I was missing out on something. I personally find the first way preferable (dropping out of PHP then back in) as it helps draw a clear distinction between PHP and HTML and also lets you make use of code highlighting and hinting for your HTML, which is always handy.

    Read the article

  • SSAS Cube reprocessing fails - then succeeds if I try again

    - by EdgarVerona
    So I'm basically brand new to the concept of BI, and I've inherited an existing ETL process that is a two step process: 1) Loads the data into a database that is only used by the cube processing 2) Starts off the SSAS cube processing against said database It seems pretty well isolated, but occasionally (once a week, sometimes twice) it will fail with the following exception: "Errors in the OLAP storage engine: The attribute key cannot be found" Now the interesting thing is that: 1) The dimension having the issue is not usually the same one (i.e. there's no single dimension that consistently has this failure) 2) The source table, when I inspect it, does actually contain the attribute key that it says could not be found And, most interestingly... 3) If I then immediately reprocess the dimensions and cubes manually through SSMS, they reprocess successfully and without incident. In both the aforementioned job and when I reprocess them through SSMS, I am using "ProcessFull", so it should be reprocessing them completely. Has anyone run into such an issue? I'm scratching my head about it... because if it was a genuine data integrity issue, reprocessing the cube again wouldn't fix it. What on earth could be happening? I've been tasked with finding out why this happens, but I can neither reproduce it consistently nor can I point to a data integrity problem as the root cause. Thanks for any input you can provide!

    Read the article

  • Website often sticks, but clicking the link again everything loads fine

    - by Dave
    Hi I have a website, which normally is very fast, however in the last week or two we're run into a problem whereby randomly if you click a link the browser will just sit there with the throbber spinning but the page doesn't appear to load If you click the link again it then responds straight away This doesn't seem to be limited to Chrome, Firefox or IE as we've tried all with all having same problems The site is build in ASP and connects to a MySQL database and runs on a dedicated windows 2003 server The firewalls were changed in the data centre recently to pixies but I've not been able to reproduce the problem outside of the office Within the office, we have 11 people (only 7 today and still experiencing problems) connected to a 7MB ADSL connection with Eclipse I have made some changes to the network in the office, namely wiring 4 desks back to the main 24 port switch rather than to small 5 port which then linked on to the 24 port switch... however we were having problems before this was done, and I did this to try and rule out an issue with the switch We have a backup ADSL connection, so I may try switching to that, or switching to a different router, but do you think this is a likely issue? Failing that, what else would you check? Thanks, sorry for length! Dave

    Read the article

  • .NET Thread.Abort again

    - by hoodoos
    Again I want to talk about safety of the Thread.Abort function. I was interested to have some way to abort operations which I can't control really and don't want actually, but I want to have my threads free as soon as possible to prevent thread thirsty of my application. So I wrote some test code to see if it's possible to use Thread.Abort and have the aborting thread clean up resources propertly. Here's code: int threadRunCount = 0; int threadAbortCount = 0; int threadFinallyCount = 0; int iterations = 0; while( true ) { Thread t = new Thread( () => { threadRunCount++; try { Thread.Sleep( Random.Next( 45, 55 ) ); } catch( ThreadAbortException ) { threadAbortCount++; } finally { threadFinallyCount++; } } ); t.Start(); Thread.Sleep( 45 ); t.Abort(); iterations++; } So, so far this code worked for about 5 mins, and threadRunCount was always equal to threadFinally and threadAbort was somewhat lower in number, because some threads completed with no abort or probably got aborted in finally. So the question is, do I miss something?

    Read the article

  • Post method in Servlet is not being called again after being executed once

    - by SaurabhCsIITKgp
    I am implementing a database based web application using servlets. Now, when I input a parameter using a form in the jsp page, it redirects it to a servlet which subsequently adds the value to the database (the servlet creates a new table if the table doesn't already exist). The creation of the table and the addition of value works fine if the table doesn't already exists. Once it is created however and the parameter is inputted again in the form, the submit button no longer redirects it to the servlet. Nor is the value added to the database. Kindly advise me as to where I am going wrong. Following are the snippets of my code: From the JSP page (/showmanager is the urlpattern of the servlet): <form action="showmanager" method="post"> <h3>Enter name of the show: </h3> <input type="text" name="showname" value=""> <input type="hidden" name="task" value="addshow" /> <input type="button" value="Add Show"> </form> From the servlet (POST method): p rotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if(request.getParameter("task").equals("addshow")){ this.addShow(request.getParameter("showname")); response.sendRedirect("showmanager.jsp"); } } Method to add in database: protected boolean addShow(String showname){ try{ statement =con.prepareStatement("INSERT INTO showdb10(name) VALUES ('"+showname+"')"); if(statement.executeUpdate()>0){ return true; } } catch(Exception e) { try{ statement =con.prepareStatement("create table showdb10 (id int NOT NULL AUTO_INCREMENT, name varchar(255) NOT NULL, date varchar(20),time varchar(20), b_total int, o_total int, b_avbl int, o_avbl int, b_price double(10,2), o_price double(10,2), seat_no varchar(20), transaction_id varchar(255), total_sales double(10,2), paymnt_artists double(10,2), paymnt_othr double(10,2), flag varchar(20), PRIMARY KEY(id))"); statement.executeUpdate(); statement =con.prepareStatement("INSERT INTO showdb10(name) VALUES ('"+showname+"')"); if(statement.executeUpdate()>0){ return true; } }catch(Exception e2){} } return false; }

    Read the article

  • call addsubview again causes slowdown

    - by Tom
    hi guys, i am writing a little music-game for the iphone. I am almost done, this is the only issue which keeps me from rolling it out. any help to solve this is much appreciated. this is what i do: at my appDelegate I add my menu-view-screen to the window. the menu-view-screen acts as a container and controls which view gets presented to the user. means, on the menu-view-screen I got 4 buttons (new game, options, faq, highscore). when the user clicks on a button something as this happens: if (self.gameViewController == nil) { GameViewController *viewController = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil]; self.gameViewController = viewController; [viewController release]; } [self.view addSubview:self.gameViewController.view]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSwitchViewNotificationFromGameView:) name:@"SwitchView" object:gameViewController]; when the user returns to the menu, this piece of code gets executed: [[NSNotificationCenter defaultCenter] removeObserver:self]; [self.gameViewController viewWillDisappear:YES]; [self.gameViewController.view removeFromSuperview]; this works fine for all screens but not for the gamescreen(well this is the only one with heaps of user-interaction) means the responsiveness of the iphone(when playing tones) gets really slow. The performance is fine when I display the gameview for the first time. it starts getting slower as soon as I add it to the menu-views-container-subviews again (addsubview) (basically open up a new game) any ideas what causes(or to get around) this? thanks heaps Best regards Tom

    Read the article

  • Form submitted via dialog opens dialog again

    - by VikingGoat
    I have a form in a jquerymobile dialog box that I am submitting via jQuery Ajax. Currently my problem is that once the form is submitted the same dialog box is opened again on top of the original dialogbox. So that my url reads before submission: url/index.php#&ui-state=dialog and then after submission: url/index.php#&ui-state=dialog#&ui-state=dialog&ui-state=dialog Has anyone ever encountered something like this before? [edit added code example] $(function(){ $("#form").submit(function(e){ e.preventDefault(); var dataString = $("#form").serialize(); errorInput = $("input[name=valOne]#valOne").val(); $.ajax({ type: "GET", url: "formHandler.php", data: dataString, dataType: "text", success: function(data){ if(data.toLowerCase().indexOf("error") >= 0){ alert(data); $(".ui-dialog").dialog("close"); $("#valOne").val(errorInput); //the reentering info so user doesn't have to }else{ $(".ui-dialog").dialog("close"); location.href="index.php"; } }, error:function (xhr, ajaxOptions, thrownError){ alert(thrownError); } }); }); });

    Read the article

  • Constructor being called again?

    - by Halo
    I have this constructor; public UmlDiagramEntity(ReportElement reportElement, int pageIndex, Controller controller) { super(reportElement.getX1(), reportElement.getY1(), reportElement.getX2(), reportElement.getY2()); setLayout(null); this.pageIndex = pageIndex; this.controller = controller; reportElements = reportElement.getInternalReportElements(); components = new ArrayList<AbstractEntity>(); changedComponentIndex = -1; PageListener p = new PageListener(); this.addMouseMotionListener(p); this.addMouseListener(p); setPage(); } And I have an update method in the same class; @Override public void update(ReportElement reportElement) { if (changedComponentIndex == -1) { super.update(reportElement); } else { reportElements = reportElement.getInternalReportElements(); if (components.size() == reportElements.size()) { if (!isCommitted) { if (reportElement.getType() == ReportElementType.UmlRelation) { if (checkInvolvementAndSet(changedComponentIndex)) { anchorEntity(changedComponentIndex); } else { resistChanges(changedComponentIndex); } return; } } ..................goes on When I follow the flow from the debugger, I see that when update is called, somewhere in the method, the program goes into the constructor and executes it all over again (super, pageIndex, etc.). Why does it go to the constructor :D I didn't tell it to go there. I can make a deeper analysis and see where it goes to the constructor if you want. By the way, changedComponentIndex is a static variable.

    Read the article

  • C++ reference variable again!!!

    - by kumar_m_kiran
    Hi All, I think most would be surprised about the topic again, However I am referring to a book "C++ Common Knowledge: Essential Intermediate Programming" written by "Stephen C. Dewhurst". In the book, he quotes a particular sentence (in section under Item 5. References Are Aliases, Not Pointers), which is as below A reference is an alias for an object that already exists prior to the initialization of the reference. Once a reference is initialized to refer to a particular object, it cannot later be made to refer to a different object; a reference is bound to its initializer for its whole lifetime Can anyone please explain the context of "cannot later be made to refer to a different object" Below code works for me, #include <iostream> using namespace std; int main(int argc, char *argv[]) { int i = 100; int& ref = i; cout<<ref<<endl; int k = 2000; ref = k; cout<<ref<<endl; return 0; } Here I am referring the variable ref to both i and j variable. And the code works perfectly fine. Am I missing something? I have used SUSE10 64bit linux for testing my sample program. Thanks for your input in advance.

    Read the article

  • Marshal.PtrToStructure (and back again) and generic solution for endianness swapping

    - by cgyDeveloper
    I have a system where a remote agent sends serialized structures (from and embedded C system) for me to read and store via IP/UDP. In some cases I need to send back the same structure types. I thought I had a nice setup using Marshal.PtrToStructure (receive) and Marshal.StructureToPtr (send). However, a small gotcha is that the network big endian integers need to be converted to my x86 little endian format to be used locally. When I'm sending them off again, big endian is the way to go. Here are the functions in question: private static T BytesToStruct<T>(ref byte[] rawData) where T: struct { T result = default(T); GCHandle handle = GCHandle.Alloc(rawData, GCHandleType.Pinned); try { IntPtr rawDataPtr = handle.AddrOfPinnedObject(); result = (T)Marshal.PtrToStructure(rawDataPtr, typeof(T)); } finally { handle.Free(); } return result; } private static byte[] StructToBytes<T>(T data) where T: struct { byte[] rawData = new byte[Marshal.SizeOf(data)]; GCHandle handle = GCHandle.Alloc(rawData, GCHandleType.Pinned); try { IntPtr rawDataPtr = handle.AddrOfPinnedObject(); Marshal.StructureToPtr(data, rawDataPtr, false); } finally { handle.Free(); } return rawData; } And a quick example structure that might be used like this: byte[] data = this.sock.Receive(ref this.ipep); Request request = BytesToStruct<Request>(ref data); Where the structure in question looks like: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] private struct Request { public byte type; public short sequence; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public byte[] address; } What (generic) way can I swap the endianness when marshalling the structures? My need is such that the locally stored 'public short sequence' in this example will be little-endian for displaying to the user. I don't want to have to swap the endianness on a structure-specific way. My first thought was to use Reflection, but I'm not very familiar with that feature. Also, I hoped that there would be a better solution out there that somebody could point me towards. Thanks in advance :)

    Read the article

  • sorry for asking again the same user here help me out

    - by jazz
    i copied a game from a book which name is paratrooper i ask this question again i also provide the code of the objects which i create there i want to change the color of these objects but i didn't understand how to do that so can any one plz help me how to do that.Listen guys they are not the standard functions but i use the graphics library for these functions and i can't find the function in the library file of graphics. i hope u understand know.this code will not run properly so plz tell me something about the function which color it i can't put the image other wize i show u the image it will make alot easieer #include "graphics.h" #include "stdio.h" #include "conio.h" #include "process.h" #include "alloc.h" #include "stdlib.h" #include "math.h" #include "dos.h" main() { int gm=CGAHI, gd=CGA, key=0, area; initgraph(&gd, &gm, "C:\tc\bgi"); helidraw(246,50,-1); getch(); return 0; } helidraw ( int x, int y, int d ) { int direction, i, j ; if ( d ) direction = -1 ; else direction = 1 ; i = 3 ; j = 8 ; line ( x - j - 8, y - i - 2, x + j + 8, y - i - 2 ) ; line ( x - j + 5, y - i - 1, x + j - 5, y - i - 1 ) ; line ( x - j, y - i, x + j, y - i ) ; for ( ; i 0 ; i--, j += 2 ) { putpixel ( x - ( direction * j ), y - i, 1 ) ; line ( x + ( direction * j ), y - i, x + ( direction * ( j - 8 ) ), y - i ) ; } i = 0 ; j -= 2 ; line ( x - ( direction * j ), y - i, x - ( direction * ( j + 17 ) ), y - i ) ; line ( x - ( direction * j ), y - i + 1, x - ( direction * ( j + 7 ) ), y - i + 1 ) ; putpixel ( x - ( direction * ( j + 19 ) ), y - i - 1, 1 ) ; for ( ; i < 3 ; i++, j -= 2 ) { putpixel ( x - j, y + i, 1 ) ; putpixel ( x + j, y + i, 1 ) ; } line ( x - j, y + i, x + j, y + i ) ; putpixel ( x - j + 3, y + i + 1, 1 ) ; putpixel ( x + j - 3, y + i + 1, 1 ) ; line ( x - j - 10, y + i + 2, x + j + 10, y + i + 2 ) ; putpixel ( x + ( direction * ( j + 12 ) ), y + i + 1, 1 ) ; }

    Read the article

  • On screen orientation loads again data with Async Task

    - by Zookey
    I make Android application with master/detail pattern. So I have ListActivity class which is FragmentActivity and ListFragment class which is Fragment It all works perfect, but when I change screen orientation it calls again AsyncTask and reload all data. Here is the code for ListActivity class where I handle all logic: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); getActionBar().setTitle("Dnevni horoskop"); if(findViewById(R.id.details_container) != null){ //Tablet mTwoPane = true; //Fragment stuff FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); DetailsFragment df = new DetailsFragment(); ft.add(R.id.details_container, df); ft.commit(); } pb = (ProgressBar) findViewById(R.id.pb_list); tvNoConnection = (TextView) findViewById(R.id.tv_no_internet); ivNoConnection = (ImageView) findViewById(R.id.iv_no_connection); list = (GridView) findViewById(R.id.gv_list); if(mTwoPane == true){ list.setNumColumns(1); //list.setPadding(16,16,16,16); } adapter = new CustomListAdapter(); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { pos = position; if(mTwoPane == false){ Bundle bundle = new Bundle(); bundle.putSerializable("zodiac", zodiacFeed); Intent i = new Intent(getApplicationContext(), DetailsActivity.class); i.putExtra("position", position); i.putExtras(bundle); startActivity(i); overridePendingTransition(R.anim.right_in, R.anim.right_out); } else if(mTwoPane == true){ DetailsFragment fragment = (DetailsFragment) getSupportFragmentManager().findFragmentById(R.id.details_container); fragment.setHoroscopeText(zodiacFeed.getItem(position).getText()); fragment.setLargeImage(zodiacFeed.getItem(position).getLargeImage()); fragment.setSign("Dnevni horoskop - "+zodiacFeed.getItem(position).getName()); fragment.setSignDuration(zodiacFeed.getItem(position).getDuration()); // inflate menu from xml /*if(menu != null){ MenuItem item = menu.findItem(R.id.share); Toast.makeText(getApplicationContext(), item.getTitle().toString(), Toast.LENGTH_SHORT).show(); }*/ } } }); if(!Utils.isConnected(getApplicationContext())){ pb.setVisibility(View.GONE); tvNoConnection.setVisibility(View.VISIBLE); ivNoConnection.setVisibility(View.VISIBLE); } //Calling AsyncTask to load data Log.d("TAG", "loading"); HoroscopeAsyncTask task = new HoroscopeAsyncTask(pb); task.execute(); } @Override public void onConfigurationChanged(Configuration newConfig) { // TODO Auto-generated method stub super.onConfigurationChanged(newConfig); } class CustomListAdapter extends BaseAdapter { private LayoutInflater layoutInflater; public CustomListAdapter() { layoutInflater = (LayoutInflater) getBaseContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE); } public int getCount() { // TODO Auto-generated method stub // Set the total list item count return names.length; } public Object getItem(int arg0) { // TODO Auto-generated method stub return null; } public long getItemId(int arg0) { // TODO Auto-generated method stub return 0; } public View getView(int position, View convertView, ViewGroup parent) { // Inflate the item layout and set the views View listItem = convertView; int pos = position; zodiacItem = zodiacList.get(pos); if (listItem == null && mTwoPane == false) { listItem = layoutInflater.inflate(R.layout.list_item, null); } else if(mTwoPane == true){ listItem = layoutInflater.inflate(R.layout.tablet_list_item, null); } // Initialize the views in the layout ImageView iv = (ImageView) listItem.findViewById(R.id.iv_horoscope); iv.setScaleType(ScaleType.CENTER_CROP); TextView tvName = (TextView) listItem.findViewById(R.id.tv_zodiac_name); TextView tvDuration = (TextView) listItem.findViewById(R.id.tv_duration); iv.setImageResource(zodiacItem.getImage()); tvName.setText(zodiacItem.getName()); tvDuration.setText(zodiacItem.getDuration()); Animation animation = AnimationUtils.loadAnimation(getBaseContext(), R.anim.push_up); listItem.startAnimation(animation); animation = null; return listItem; } } private void getHoroscope() { String urlString = "http://balkanandroid.com/download/horoskop/examples/dnevnihoroskop.php"; try { HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(urlString); HttpResponse response = client.execute(post); resEntity = response.getEntity(); response_str = EntityUtils.toString(resEntity); if (resEntity != null) { Log.i("RESPONSE", response_str); runOnUiThread(new Runnable() { public void run() { try { Log.d("TAG", "Response from server : n " + response_str); } catch (Exception e) { e.printStackTrace(); } } }); } } catch (Exception ex) { Log.e("TAG", "error: " + ex.getMessage(), ex); } } private class HoroscopeAsyncTask extends AsyncTask<String, Void, Void> { public HoroscopeAsyncTask(ProgressBar pb1){ pb = pb1; } @Override protected void onPreExecute() { pb.setVisibility(View.VISIBLE); super.onPreExecute(); } @Override protected Void doInBackground(String... params) { getHoroscope(); try { Log.d("TAG", "test u try"); JSONObject jsonObject = new JSONObject(response_str); JSONArray jsonArray = jsonObject.getJSONArray("horoscope"); for(int i=0;i<jsonArray.length();i++){ Log.d("TAG", "test u for"); JSONObject horoscopeObj = jsonArray.getJSONObject(i); String horoscopeSign = horoscopeObj.getString("name_sign"); String horoscopeText = horoscopeObj.getString("txt_hrs"); zodiacItem = new ZodiacItem(horoscopeSign, horoscopeText, duration[i], images[i], largeImages[i]); zodiacList.add(zodiacItem); zodiacFeed.addItem(zodiacItem); //Treba u POJO klasu ubaciti sve. Log.d("TAG", "ZNAK: "+zodiacItem.getName()+" HOROSKOP: "+zodiacItem.getText()); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.e("TAG", "error: " + e.getMessage(), e); } return null; } @Override protected void onPostExecute(Void result) { pb.setVisibility(View.GONE); list.setAdapter(adapter); adapter.notifyDataSetChanged(); super.onPostExecute(result); } } Here is the code for ListFragment class: public class ListFragment extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub // Retain this fragment across configuration changes. setRetainInstance(true); super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View view = inflater.inflate(R.layout.fragment_list, container, false); return view; } }

    Read the article

  • Binary to Ascii and back again

    - by rross
    I'm trying to interface with a hardware device via the serial port. When I use software like Portmon to see the messages they look like this: 42 21 21 21 21 41 45 21 26 21 29 21 26 59 5F 41 30 21 2B 21 27 42 21 21 21 21 41 47 21 27 21 28 21 27 59 5D 41 32 21 2A 21 28 When I run them thru a hex to ascii converter the commands don't make sense. Are these messages in fact something different than hex? My hope was to see the messages the device is passing and emulate them using c#. What can I do to find out exactly what the messages are?

    Read the article

  • again about JPA/Hibernate bulk(batch) insert

    - by abovesun
    Here is simple example I've created after reading several topics about jpa bulk inserts, I have 2 persistent objects User, and Site. One user could have many site, so we have one to many relations here. Suppose I want to create user and create/link several sites to user account. Here is how code looks like, considering my willing to use bulk insert for Site objects. User user = new User("John Doe"); user.getSites().add(new Site("google.com", user)); user.getSites().add(new Site("yahoo.com", user)); EntityTransaction tx = entityManager.getTransaction(); tx.begin(); entityManager.persist(user); tx.commit(); But when I run this code (I'm using hibernate as jpa implementation provider) I see following sql output: Hibernate: insert into User (id, name) values (null, ?) Hibernate: call identity() Hibernate: insert into Site (id, url, user_id) values (null, ?, ?) Hibernate: call identity() Hibernate: insert into Site (id, url, user_id) values (null, ?, ?) Hibernate: call identity() So, I means "real" bulk insert not works or I am confused? Here is source code for this example project, this is maven project so you have only download and run mvn install to check output.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >