|
Hi
Currently I am working on an application to set reminders on monthly basis. I am not able to provide the correct repeating interval for my alarmmanager. Pls provide info about the same. this is my code, but this will not raise alarm for Feb or months having 30 days. Also pls provide code to set yearly repeating alaram.
repeatTime=(AlarmManager.INTERVAL_DAY*31);
mAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, when.getTimeInMillis(), repeatTime, pi);
Thanks,
Sharath
|
|
|
|
|
You need to add logic to calculate how many days to add, depending on the number of days in the current month. Then each time your application runs it sgould reset the alarm to the new value.
|
|
|
|
|
As you are already (hopefully) aware, hard-coding numbers into your code is a bad idea.
When are you wanting the alarm set for (e.g., the last day of the month)?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
hi my code is bellow but it doesnt scroll(everything is for TabHost Not FragmentTabHost) and The tabhost is shrinking and the tab text showing in a second link also.
I want to add Horizontal scroll only for my tabhost.
However we can add swipe able tab. but i don't want this. i want to swipe only the tabhost. not the tab content.
Thanks in advance.
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.app.FragmentTabHost android:id="@+id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:id="@+id/layTab"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none" >
<TabWidget
android:id="@+id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TabWidget>
</HorizontalScrollView>
</RelativeLayout>
<FrameLayout
android:id="@+id/tabContentsHere"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/layTab"
android:layout_alignParentTop="true" />
</android.support.v4.app.FragmentTabHost>
|
|
|
|
|
Hi... I am using visual studio 2012 for Android App. How to display listview with text and images. please guide me guys.. its urgent....
|
|
|
|
|
Try looking for some samples with Google[^]. And, please, do not tell us it's urgent, we have our own priorities.
|
|
|
|
|
|
I am using FragmentTabHost in xamarin C# and i get error in :
mTabHost.AddTab(spec);
and the whole project is :(Part that you may need)
Activity 2.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Content.PM;
using Android.Support.V4.App;
namespace ANRestaurant.Forms
{
[Activity(Label = "ANRestaurant", MainLauncher = true, Icon = "@drawable/icon", ScreenOrientation = ScreenOrientation.Portrait)]
public class Activity2 : FragmentActivity
{
FragmentTabHost mTabHost;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.activity_main);
try
{
mTabHost = FindViewById<FragmentTabHost>(Resource.Id.tabhostN );
Intent intent;
intent = new Intent(this, typeof(Fragment1));
intent.AddFlags(ActivityFlags.NewTask);
TabHost.TabSpec spec;
spec = mTabHost.NewTabSpec("artists");
spec.SetIndicator("Artists", Resources.GetDrawable(Resource.Drawable.tab_icon1) );
spec.SetContent(intent);
mTabHost.AddTab(spec); <code><big>======>Here the error occered!</big></code>
}
catch (Exception ex)
{
}
}
}
}
activity_main.axml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhostN"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal" />
<FrameLayout
android:id="@+id/tabFrameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
Fragment1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
namespace ANRestaurant.Forms
{
public class Fragment1 : Fragment
{
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.Inflate(Resource.Layout.fragment1, container, false);
return view;
}
}
}
fragment1.axml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#AA1111">
<TextView
android:id="@+id/txtF"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="This is Tab 1"
android:textSize="20sp"
android:textColor="#dddddd"
android:layout_centerInParent="true" />
</RelativeLayout>
<big>And THE ERROR IS :</big>
{Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown.
at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00063] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/98634deb/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:507
at Android.Widget.TabHost.AddTab (Android.Widget.TabSpec tabSpec) [0x00043] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/98634deb/source/monodroid/src/Mono.Android/platforms/android-12/src/generated/Android.Widget.TabHost.cs:801
at ANRestaurant.Forms.Activity2.OnCreate (Android.OS.Bundle bundle) [0x00079] in e:\Home\Herman resturant Android\Source\ANRestaurant\ANRestaurant\Forms\Act ivity2.cs:39
--- End of managed exception stack trace ---
java.lang.NullPointerException
at android.widget.TabHost.addTab(TabHost.java:236)
at anrestaurant.forms.Activity2.n_onCreate(Native Method)
at anrestaurant.forms.Activity2.onCreate(Activity2.ja va:28)
at android.app.Activity.performCreate(Activity.java:5 104)
at android.app.Instrumentation.callActivityOnCreate(I nstrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThre ad.java:141)
at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99 )
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.jav a:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:560)
at dalvik.system.NativeStart.main(Native Method)
}
modified 8-Sep-14 6:25am.
|
|
|
|
|
According to my counting, the line you have marked is not line 39, as referenced in the error message. However, I suspect that the variable mTabHost has not been set to point to anything. Are you sure you get a valid reference returned in the following statement?
mTabHost = FindViewById<FragmentTabHost>(Resource.Id.tabhostN );
|
|
|
|
|
first of all thanks for ur attention.
i have it in "activity_main.axml" :
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhostN"
android:layout_width="match_parent"
android:layout_height="match_parent">
And the mTabHost isnot nulll in
mTabHost = FindViewById<FragmentTabHost>(Resource.Id.tabhostN );
Or
Possible to give me and C# xamarin example for doing the same i have done?
any further question?
|
|
|
|
|
Did you actually check the value of this variable at run time? It matters not what you write in your source code, the only way to be sure it works is to check it at the time of error. If it is not that variable that causes the error then it must be one of the others.
I also notice that you have this code within a try/catch block, but you eat the exception. This is really bad practice and leads to situations just such as this. Exceptions provide useful information, so make proper use of them.
|
|
|
|
|
i have used this for sample for that the catch is not complete.
at runtime the mtabHost is not null.
i have breakepoint in
mTabHost.AddTab(spec);
and the error occured in here.
thanks in advanced!
|
|
|
|
|
Then you need to establish what value is causing the exception. We cannot guess it from the information you have provided.
|
|
|
|
|
may i give ur the whole project for downloading?
thanks in advanced!
|
|
|
|
|
Sorry, no. You need to do the debugging and provide the required information.
|
|
|
|
|
thanks
but i have done that but cannot help!
do y have any sample ?
|
|
|
|
|
Sorry, I don't use Xamarin, and that is not really the solution; if you find another sample and that one does not work, what then? If you aspire to be a developer then you really need to practice diagnosing problems, even if you need help solving them.
|
|
|
|
|
thanks for ur advice
But the error is exact there and i dont know how to solve that~
|
|
|
|
|
I have tried to explain how: you use your debugger to step through the code and look to see what variable is not being set up correctly. You can only solve it by collecting all the information around the time of error.
|
|
|
|
|
Thanks i have done that!
I should change :
mTabHost.AddTab(spec);
To :
mTabHost.Setup(this, SupportFragmentManager, Resource.Id.tabFrameLayout);
mTabHost.AddTab(spec, Java.Lang.Class.FromType(typeof(Fragment1)), null);
end of story
That is all!
|
|
|
|
|
Yes, it always helps to read the documentation.
|
|
|
|
|
I want to add a method by which I can directly print report from the printer on local network.
my server which printer is connected to is 192.168.1.50
(my printer isnt Bluetooth OR Wifi one.)
I also have seen PrinterShare but it looks like it requires a client software running on a PC connected to the printer.
I wanna to do it directly to server which has printer connected and shared!
I got this code but no USE!!!
I wanna to do that in (xamarin C#)
try
{
Socket sock = new Socket("192.168.1.222", 9100);
PrintWriter oStream = new PrintWriter(sock.getOutputStream());
oStream.println("HI,test from Android Device");
oStream.println("\n\n\n");
oStream.close();
sock.close();
}
catch (UnknownHostException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
Thanks in advacned!
|
|
|
|
|
jojoba20 wrote: I got this code but no USE!!! You need to explain why it is no use. Did you get some sort of error, and if so please edit your question and add the details.
|
|
|
|
|
it needs wifi printer but mine is only connected to PC(server) and the printer is shared
|
|
|
|
|
jojoba20 wrote: it needs wifi printer but mine is only connected to PC I don't think there is a lot that we can do to help with that.
|
|
|
|