Member Avatar

Hi, How can I pass a c# string to C++ side of the app? Right now, I have all handling in Const char * format . When I pass c# string, c++ working fine when using Platform::String . But there is no good way of converting Platform::String to const char *. Any inputs from your side? Any help will be appreciated. Thanks.

Member Avatar
0
68
Member Avatar

Hi, I am facing an issue in string to const char pointer conversion. I am doing stuff in the fun() but here i am just giving my example. Here it the code: // Helper function string fun() { string abc = "Daniweb"; // print here #1 return abc; } // main function int main() { const char * returnValue = fun().c_str(); // print here #2 string returnValue2 = fun().c_str(); // print here #3 } When I print the value in fun() function before returning it, it is printing fine. (#1) When I print the value after const char (#2), it …

Member Avatar
0
71
Member Avatar

Hi guys, Here is the question: I have Activity A, Activity B. Now, A --> B . Now, pressed the home button. Now, go to any image & "open with" will show my app. when pressing my app as the option, it will hit Activity A. When it will hit A, intent is handled in this activity. At this stage, A & B are already in the stack. I want to discard all the activities except A. I have done it by restarting the activity using CLEAR_TASK intent (basically a restarter). But problem comes when my app was not opened …

0
6
Member Avatar

Hi everyone, How are you? Starting some thread after long time :) Actually, I have a group of 25 people. I have 20-25 mobile devices in my group. So, I have assigned 1-2 device on each person's name(as an owner). But, people in the group ask each other for the device for some help and promise to return it too. They may need specific device for some work which is a genuine thing. But, they forget to return it & person who gave has to ask on emails or each person where his/her device is. Problem: Asking on emails is …

Member Avatar
0
14
Member Avatar

Hi, I have one function (in a library I can't change the code) which takes a key and returns a Object. This code is written in java. I am calling this function from cpp code. I am accepting the result as jobject. 1. Added key as "key1" & value as boolean true by calling a function. it saves in a map after converting in into java BooleanObject. 2. When I get it back I get it back as Object. I want to compare it with true now. How can I do that? Thanks in advance.

Member Avatar
0
23
Member Avatar

Hi, I have been working on JNI. I have one doubt. When I call any native method from android activity (Java code), then we get jclass object from jobject instance we get in the native method as a parameter. Why do we need it actually? Here is a snippet from one website: JNIEXPORT void JNICALL Java_TestJNIInstanceVariable_modifyInstanceVariable (JNIEnv *env, jobject thisObj) { // Get a reference to this object's class jclass thisClass = (*env)->GetObjectClass(env, thisObj); // int // Get the Field ID of the instance variables "number" jfieldID fidNumber = (*env)->GetFieldID(env, thisClass, "number", "I"); if (NULL == fidNumber) return; // Get …

0
6
Member Avatar

Hi, I have one CSS. .buttonSize { min-width : 58% } Actually, I have two buttons, with text "Hovers" & "Copy". My button without any css taking spaces which can wrap the text size. This way size of two buttons is not same. What I tried: a) I have hacked by adding two spaces to "copy" and tried. On some browsers, it worked fine but on mozilla it was taking little more space(as compared to hovers button). b) I have added the css class above & added in the tags of the buttons. worked fine on all browsers on all …

Member Avatar
0
12
Member Avatar

Hey, I have been reading Java oracle tutorials. I read this thing. Suppose, for example, class MsLunch has two instance fields, c1 and c2, that are never used together. All updates of these fields must be synchronized, but there's no reason to prevent an update of c1 from being interleaved with an update of c2 — and doing so reduces concurrency by creating unnecessary blocking. Instead of using synchronized methods or otherwise using the lock associated with this, we create two objects solely to provide locks. public class MsLunch { private long c1 = 0; private long c2 = 0; …

Member Avatar
0
7
Member Avatar

Hi, I have been working in Java for more than 8-9 months now. I want to have deep understanding of Java concepts now. For ex: Collections properties, threading, interfaces detailed concepts etc. I mean I have been using all these things for a while now but want to know about the things of Java in detail. Can you suggest some online source/Java book or something like this which I can follow? Usually, I search on web whatever I want to study and read the top 3-4 links. But, some book or course will help me better. Thanks in advance.

Member Avatar
1
44
Member Avatar

Hi all, Actually, this question is not related to some coding or logic from my project. But, as I am doing hard and harder projects (acc. to me & my exp.), I am focussing more on design part of my projects. When I present my design to team members for the feature I have started working to get sign-off from the team, what things I should keep in my mind? Can we have this thread helpful to every developer by jotting down things we should keep in mind for succesful execution of a design phase? As we have highly experienced …

Member Avatar
0
17
Member Avatar

Hi, I am creating a form in jsp. <form action="" method="post"> <input type="hidden" name="status_1" value="0" /> <input type="checkbox" id="status_1" name="status_1" value="1" /> <input type="hidden" name="status_2" value="0" /> <input type="checkbox" id="status_2" name="status_2" value="1" /> <input type="hidden" name="status_3" value="0" /> <input type="checkbox" id="status_3" name="status_3" value="1" /> <input type="submit" /> </form> I was referring this link: http://stackoverflow.com/questions/19239536/how-get-value-for-unchecked-checkbox-in-checkbox-elements-when-form-posted So, can you tell how this is priortized? I mean if I am marking chekcbox as checked, then how does it decide which value to take in the req parameter? Also, is there any order dependent thing in this? if hidden input is written after the …

Member Avatar
1
28
Member Avatar

Hi, I am stuck with a problem. I have two Date objects (util class objects). I want the difference between these two dates as the number of days between them? I am using Java 8. Can you please help me with this? Searched the web a lot. Some are saying to use Joda, while some are using TimeUnit. Some says Timeunit not handles leap year properly etc. I am confused now. Here is the link I read: http://stackoverflow.com/questions/20165564/calculating-days-between-two-dates-with-in-java Thanks in advance.

Member Avatar
0
22
Member Avatar

Hi, I was using booleans earlier in my class. --> isProductRestricted --> internal --> isProductGlobal I am using lombok too. So putting @Data at the top of class too. But, now I changed these boolean to Boolean variable. I got errors where ever `Object.isInternal()` was used. I am not getting how isInternal() was working initially. There is no function in my class too. Also, I am able to access boolean isProductGlobal using `Object.getProductGlobal()` bit there is "is" also attached to the productGlobal name. Can you please explain this? How is it happening here? Thanks in advance.

Member Avatar
0
17
Member Avatar

Hey, I have one class Company and one Item class which is an object in Company class as shown: public abstract class Company { @Inject private ItemClass item; void companyMethod() { this.item.itemMethod(); } } public class ItemClass { public void itemMethod() { // logic } } So, many class inherits the Company abstract class say ClassA, ClassB, ClassC. So, public class ClassA extends CompanyClass { void ClassAMethod() { } String getName() { //logic } } So, now when I declare a variable of ClassA say: classAObj . I called: `classAObj.companyMethod()` Now, I want to call ClassA's getName function in ItemMethod() …

Member Avatar
0
15
Member Avatar

Hey, I have visited Daniweb after few months. I have seen "API" options in my profile. How can we use it? Is it similar to fb apis, twitter apis? Thanks.

0
5
Member Avatar

public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ParseObject.registerSubclass(MyFirstClass.class); Parse.initialize(this, "Id", "Id"); Button button = (Button)findViewById(R.id.button1); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { callSearch(); } }); ParseUser user = new ParseUser(); user.setUsername("username"); user.setPassword("password"); /*user.signUpInBackground(new SignUpCallback() { @Override public void done(ParseException arg0) { // TODO Auto-generated method stub Toast.makeText(MainActivity.this, "signed in", Toast.LENGTH_LONG).show(); } });*/ try { Thread.sleep(5000); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } MyFirstClass object = new MyFirstClass(); object.add("one", "1000"); object.add("two", "22"); object.saveInBackground(); Toast.makeText(this, "saved in server", Toast.LENGTH_SHORT).show(); try { Thread.sleep(5000); } catch (InterruptedException e) { // …

Member Avatar
0
12
Member Avatar

I have read few articles on google but I am still confused when to use what. I have come across checked and unchecked exceptions. I have one exception which I need to define. Let say, when xyz is null, I need to throw the inconsistentcyException which I will catch in the same file and that catch() block will throw one exception which extends runtime exception. This exception which I am defining newly would be used in this file only. try{ if(xyz == null) { throw new InconsistentException(); } catch(InconsistentException e) throw new AlreadyExisitingExceptionExtendingRuntimeException(); } } I need to define the …

Member Avatar
0
11
Member Avatar

Hi, Actually, I want to make one Singleton class which will create one instance for one thread. I mean if we have 10 threads, then Singleton will create only one object for one thread. IF same thread will ask for one more instance it will return the same instance. Basically, my singeton is not process-specific, it would be thread-specific. Please tell how I can think for this modification of Singleton. I don't want the code but I need the idea how to proceed for the same. May be links or snippets will help. Thanks in advance.

Member Avatar
0
15
Member Avatar

I built one Sync code. I am using eclipse for the same. Actually my code is working fine in eclipse. But when I run it in Tizen OS device. I am using beecrypt library for the same. I have one line auto_ptr<Mac>(Mac::getInstance("HmacSHA256")); Actually, it is throwing exception on this line. I have installed beecrypt in Phone, then ran the Sync code but it is saying (exception message) HmacSHA256 not Available What can be the problem? I am using: - C++ - beecrypt library - Eclipse Juno - Ubuntu 12.04 Both sync code and beecrypt are built properly. Sync code is …

0
14
Member Avatar

I have made very simple code to larn the functionality. String str = "ABC"; InputStream input = new ByteArrayInputStream(str.getBytes()); BufferedReader reader = new BufferedReader(new InputStreamReader(input)); System.out.println(Character.valueOf((char) reader.read())); System.out.println(reader.read()); System.out.println(reader.read()); System.out.print(reader.read()); Secondly this one, String str = "ABC"; InputStream input = new ByteArrayInputStream(str.getBytes("UTF-8")); System.out.print(input.read()); System.out.print(input.read()); } output is same for the ways. Which way is good, and when should I use the each one of them? Thanks.

Member Avatar
1
24
Member Avatar

I have one project named P2PTicTac. I have one file named layout.java. and one with CLient.java. I have made simple GridView in layout file with 9 buttons in 3*3 Grid. I have run two threads in client.java. One for reading the data from server and one for writing data to server. I have actionListeners in Layout file. When I click on any button in layout , then I want to send one number to server using the thread which I run in client.java. And then server will send me a number which I will use to update my GUI in …

Member Avatar
0
20
Member Avatar

public class Input { static InputStream reader = null; /** * @param args * @throws IOException * @throws InterruptedException */ public static void main(String[] args) throws IOException, InterruptedException { Test test = new Test(); test.start(); String str = "1 21"; // Scanner scan = new Scanner(System.in); try { reader = new ByteArrayInputStream(str.getBytes("UTF-8")); System.setIn(reader); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } class Test extends Thread { public void run() { super.run(); try { getSum(); } catch (InterruptedException e) { e.printStackTrace(); } } private void getSum() throws InterruptedException { Scanner scan = new Scanner(System.in); int x = scan.nextInt(); int y …

Member Avatar
0
10
Member Avatar

I read about cherry-picking. It says: You have one branch x1 and branch x2. You want to take one commit from many commits of x2 and want to merge it with x1. You have 4-5 commits in x1 and now you take one commit or range of them and want to merge it with x2. It is cherry-picking. We can do using: git cherry-pick ID Is this correct what I got about cherry-picking? Secondly, It says: you have some consequences when you cherry-pick the commits. **This changing of commit IDs breaks git's merging functionality among other things (though if used …

Member Avatar
0
29
Member Avatar

I read many articles on Web regarding this. I am able to understand what static_cast does. I am not to properly understand why, and when we have to dynamic cast. There is something "we can downcast the pointer when it is polymorphic". I am not able to understand what they meant by this. Can anyone please explain with one good example? In short, Use of static cast and dynamic cast? Any help would be appreciated. Thanks in advance.

Member Avatar
0
32
Member Avatar

Hi, I am learning Git system these days. I have made a new folder in ubuntu and in terminal did this: 1. git init 2. then made a file testfile1.txt 3. then made a branch using "git branch newbranch" 4. then checkout to this branch. 5. then, made a new file in the branch testfile2.txt and added some content. 6. then i switched to master branch. 7. then "ls". there also I was able to see this file. (BIG DOUBT, why I saw this file in master branch.) 8. Then I switched again to newbranch and "git add ." --> …

Member Avatar
0
29
Member Avatar

#include<iostream> using namespace std; class Singleton { static Singleton * s; Singleton() { } public: ~Singleton() { s = NULL; } static Singleton * getInstance(); void print() { cout<<this<<endl; } }; Singleton* Singleton::s=NULL; Singleton* Singleton::getInstance() { if(s == NULL) { s = new Singleton(); } return s; } int main() { Singleton * s = Singleton::getInstance(); s->print(); Singleton * s2 = Singleton::getInstance(); s2->print(); return 0; } Singleton* Singleton::s=NULL; (line 23) When I am not putting this line, it is saying that undefined reference to 's'. By default static members are NULL only. then why does it need me to put …

Member Avatar
0
45
Member Avatar

#include<iostream> using namespace std; int add(int x,int y) { int ans=0; int carry=0; for(int i=0;i<=31;i++) { int p = (1<<i)&x; int q = (1<<i)&y; int r = p ^ q; r = r^(carry<<i); ans = r | ans; if(p&q || p&(carry<<i) || q&(carry<<i)) carry = 1; else carry =0; } return (ans); } int main() { int x,y; x=-2;y=6; //add(4,6); cout<<endl<<add(x,y)<<endl; return 0; } Actually, I am trying to add bit by bit. When number is negative, it is represented by 2's compliment. But, here I am using the 32th leftmost bit. Isn't it wrong? It is giving corrent for …

Member Avatar
0
36
Member Avatar

I have come across one question: find the size of two 2-D arrays when double pointers are given for them.Then find, if we can muliply these two matrices(those mathematics rules). finally we have to multiply the matrices. I have asked this question(small part of this question) earlier also. someone answered that it is not possible to get the size like this. I aksed for the single-D array. I know same would be applied for the 2D arrays also. but, what might he be expecting from the person who is going to answer this? How can we find the sizes using …

Member Avatar
0
11
Member Avatar

Why can we virtual destructors but can't have virtual constructors? I have searched like anything. I got confused a lot after reading few articles on web. Please explain with some good example. Thanks in advance.

Member Avatar
0
37
Member Avatar

I am working on a project and I need one CmakeList.txt file, Config file, spec file. I searched a lot. tutorials are telling how to make these files and all. Please tell me from scratch what they are and what is the use of these files? Please provide links also where I can learn about these files. Any help would be appreciated. Thanks in advance.

Member Avatar
0
26

The End.